Sometimes when working with C# you discover some hidden gems. Some of them very usefull, other ones a little bit harder to find a good way to benefit from their functionality. One of those hidden gems that I discovered some days ago is a hidden feature of the DebuggerDisplay attribute.
You probably already know the DebuggerDisplayAttribute. It allows you to tell the debugger what information to show in the IDE during a debug session.
For example, when we debug the following class:
you’ll see this information in the debugger:
So far nothing new, but did you know that you can also use this for types you don’t own?
Imagine that the Product class above was part of another assembly we don’t own and didn’t had the DebuggerDisplayAttribute.
What we can do is set an attribute at the assembly level like this:
This has the same effect in the debugger. Nice!