IntelliTrace 参数引用

IntelliTrace Arguments By Reference

使用 IntelliTrace,我无法在同一事件中(或根本看不到)通过引用传递到方法中的字符串的输出和方法的结果。

方法示例:

public bool ByReferenceTestMethod(System.ArgumentNullException exception, ref string referenceArgument)
{
    referenceArgument = string.Format("referenceArgument{0}", exception.Message);
    return true;
}

collectionplan.xml 没有引用参数引用的示例:

<DiagnosticEventSpecification>
    <CategoryId>Whosebug.test.application</CategoryId>
    <SettingsName _locID="settingsName.Test.Application.Reference">VerifyIDFromBackEnd called</SettingsName>
    <SettingsDescription _locID="settingsDescription.Test.Application.Reference">VerifyIDFromBackEnd was called</SettingsDescription>
    <Bindings>
        <Binding onReturn="false">
            <ModuleSpecificationId>Whosebug.test.application</ModuleSpecificationId>
            <MethodName>ByReferenceTestMethod</MethodName>
            <MethodId>Test.Application.TestClass.ByReferenceTestMethod(System.ArgumentException,System.String&amp;):System.Boolean</MethodId>
            <ShortDescription _locID="shortDescription.Test.Application.Reference.called">Method 'ByReferenceTestMethod' called</ShortDescription>
            <LongDescription _locID="longDescription.Test.Application.Reference.called">ByReferenceTestMethod called with ArgumentException parameter name "{0}" and message "{1}"</LongDescription>
            <TypeName>Test.Application.TestClass</TypeName>
            <DataQueries>
                <DataQuery index="1" maxSize="2048" type="String" name="Exception parameter" _locID="dataquery.Test.Application.Reference.exception.Paramname" query="m_paramName" />
                <DataQuery index="1" maxSize="2048" type="String" name="Exception message" _locID="dataquery.Test.Application.Reference.exc5eption.Message" _locAttrData="name" query="_message" />
        </DataQueries>
        </Binding>
        <Binding onReturn="true">
            <ModuleSpecificationId>Whosebug.test.application</ModuleSpecificationId>
            <MethodName>ByReferenceTestMethod</MethodName>
            <MethodId>Test.Application.TestClass.ByReferenceTestMethod(System.Exception,System.String&amp;):System.Boolean</MethodId>
            <ShortDescription _locID="shortDescription.Test.Application.Reference.result">Method 'ByReferenceTestMethod' completed</ShortDescription>
            <LongDescription _locID="longDescription.Test.Application.Reference.result">ByReferenceTestMethod returned result "{0}" with an unknown referenceArgument</LongDescription>
            <TypeName>Test.Application.TestClass</TypeName>
            <DataQueries>
                <DataQuery index="-1" maxSize="0" type="Boolean" name="Reference Result" _locID="dataquery.Test.Application.Reference.result" _locAttrData="name" query="" />
            </DataQueries>
        </Binding>
    </Bindings>
</DiagnosticEventSpecification>

collectionplan.xml 示例不适用于参考参数参考:

<LongDescription _locID="longDescription.Test.Application.Reference.result">ByReferenceTestMethod returned result "{0}" with referenceArgument "{1}"</LongDescription>
<TypeName>Test.Application.TestClass</TypeName>
<DataQueries>
    <DataQuery index="-1" maxSize="0" type="Boolean" name="Reference Result" _locID="dataquery.Test.Application.Reference.result" _locAttrData="name" query="" />
    <DataQuery index="2" maxSize="4096" type="String" name="referenceArgument" _locID="dataquery.Test.Application.Reference.Reference.Value" _locAttrData="name" query="" />
</DataQueries>

这显示了没有已解析标记的 LongDescription,如果我更改顺序,消息本身根本不会出现。

据我了解,ref 应该在 onResult="true" 时出现,因为该事件直到方法 returns 之后才会被评估。如果我在 onResult="false" 数据查询中使用相同的参数,那么在该方法可能设置值之前对其进行评估。

我做错了什么?

据我所知,你不能为所欲为。过去我曾多次尝试做同样的事情,但没有成功。但是,问题不在于 ref 参数。它也不适用于 "normal" 参数。

如果您使用 onReturn="true",那么您只能引用从方法 return 编辑的值,即 index="-1"。在这种情况下,您无法读取参数值。这是由于 IntelliTrace 在后台的工作方式,我不知道解决方法。

可编程数据查询也无济于事。 PDQ有两种实现方法:

  • object[] EntryQuery(object thisArg, object[] args)
  • object[] ExitQuery(object returnValue)

调用第一个来分析输入参数 (onReturn="false"),调用第二个来分析 return 值 (onReturn="false")。同样,在 ExitQuery 中,您只能访问 return 值。