During the debugging session, I always had problems with complex structures. Preview most interesting properties were irritating, we need to expand a variable.
In most cases, I tried to override ToString
method. But it isn't always possible.
Default tooltip is useless. Just look on it:
Adding an attribute
Probably You won't believe me, but a few years ago, in .NET 2.0 times, Microsoft introduced DebuggerDisplayAttribute
, which is very useful. Just add it like below:
[DebuggerDisplay("Range=<{RangeStart}; {RangeEnd})")]
class Range
{
public int Start;
public int End;
//Other stuff
}
Now, tooltip looks great. Moreover, your class doesn't change at all. Just check it out:
More awesome stuff
Another great attribute is DebuggerBrowsableAttribute
and DebuggerTypeProxyAttribute
. Just take a look on MSDN to find out more.