• Home
  • About
  • Contact
  • Speaking

How to enhance debugging in Visual Studio with just one simple step

by Piotr Stapp — on c# visual studio 12 Sep 2016

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.


Follow @ptrstpp950

0%
How to enhance debugging in Visual Studio with just one simple step
words - read.
Recent Posts:

Comments

comments powered by Disqus
Piotr Stapp Author

Piotr Stapp

Developer, engineer, craftsmen, speaker & biker. User of all useful technologies. Believe in people not papers. DevOps & automation adept. In love with web technologies. I speak here for myself only.

Previous post How to split monolith solution - part 3 - compilation tiers In the previous article I used a term "compilation tiers", but I didn't define it. But before the definition,…
Next post 1 unbelievable trick to create an easy to consume API in .NET Creating a service for unknown technology is usually painful. Sorry, "service" is an unpopular world, nowadays we call it…
All content copyright Reset your code © 2016 • All rights reserved.
Proudly published with Ghost