Can IntelliTrace log be used to inspect value of a complex type

57 Views Asked by At

Let's say I have a class A that contains a class B which itself contains another class C. Something as follows

class A
{
  B  b;
}

class B
{
  C  c;
}

I have a method that takes instance of class A as parameter.

private void MyMethod(A a)
{

}

Let's say this class A instance passed in this method contains some data that is causing some issue and I need to figure that out. Will I be able to inspect value of A instance and any of its children if I capture IntelliTrace log?

1

There are 1 best solutions below

0
Michał Komorowski On BEST ANSWER

By default it is not possible because of two limitations of IntelliTrace i.e.:

  • IntelliTrace records/captures only values of fields/properties that that are primitive data types.

  • IntelliTrace does not analyse the object graph.

Let's extend your example:

public class A
{
   public int Prop1 { get; set; }
   public C Prop2  { get; set; }
}

In this case in IntelliTrace log you will only find a value of Prop1 because it is an int. In the case of Prop2 you will only see if it is set or not.

As the workaround you can try to define a custom diagnostic event. However, it is not so easy. You can start by reading Custom TraceSource and debugging using IntelliTrace and VS 2010 : Customize IntelliTrace events. See also this and this question.