IntelliTrace参考参考

时间:2016-08-24 16:32:44

标签: c# visual-studio-2015 intellitrace

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

方法示例:

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

collectionplan.xml示例在没有引用参数引用的情况下工作:

<DiagnosticEventSpecification>
    <CategoryId>stackoverflow.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>stackoverflow.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>stackoverflow.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,如果我更改了顺序,则消息本身根本不显示。

根据我的理解,当onResult =“true”时,ref应该出现,因为直到方法返回之后才会计算该事件。如果我在onResult =“false”dataquery中使用相同的参数,则在该值可能由该方法设置之前进行评估。

我做错了什么?

1 个答案:

答案 0 :(得分:1)

据我所知,你不能做你想做的事。我曾经尝试过几次做同样的事情而且没有用。但是,问题不在于ref参数。它也不适用于&#34; normal&#34;参数。

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

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

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

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