Some Background on why
Another thing that come out of last weeks training was Visual Studio Debuggers. This lead to me finding the coolest visualizer ever called TPL Dataflow Debugger Visualizer which allows you to easily visualize your TPL Dataflow
Because I found this awesome visualizer I decided that everything while debugging could be awesome if there were more of these so I have created a GitHub project called DotNet Pretty where I plan on creating many visualizers to really try light up the debugging experience.
What is DebuggerDisplayAttribute?
In case you don't know DebuggerDisplayAttribute is used when you want to have a "pretty" representation of the properties in your class when seeing it in the debugger.
What MSDN says
Debugger display attributes allow the developer of the type, who specifies and best understands the runtime behavior of that type, to also specify what that type will look like when it is displayed in a debugger.
How do you implement them
You simple place the DebuggerDisplay Attribute on a class like below
When the break point is hit instead of you seeing the objects ToString() implementation of the method as below
which of course you could override to show a nice message if you wanted to, you will get something like below
It doesn't seem like such a big deal with 1 object but think of how easy it would be to know stuff about objects when they in a list if they each implemented this attribute. Now obviously to use the attribute like this you need to own the object so you can add the attribute and release it.
DotNet Pretty's first contribution
The first contribution to DotNet Pretty is one that was used in the training which allows you to use the DebuggerDisplay Attribute in a different way.
Code
This time you specify the target in the attribute like below
As you can see this is just floating in a random .cs file so it doesn't have to be placed anywhere specific in the code.
What it looks like
This time instead of seeing the ToString() method
You will see
Deploying Visualizers
Now obviously Visual Studio can't do magic to find out where the visualizers are across your whole machine so to get your custom visualizers to you work you simple need to drop the output assemblies in the path C:\Users\[username]\Documents\[Visual Studio Version]\Visualizers which in my case is C:\Users\GordonB\Documents\Visual Studio 2013\Visualizers.
How is the TDL Dataflow visualizer done?
In short the TPL Dataflow visualizer uses the DebuggerVisualizerAttribute which looks something like below
I will do a in detail post on DebuggerVisualizer Attribute when I add one to DotNet Pretty. For now though you can browse the source code of the TPL Dataflow Debugger Visualizer on CodePlex.
So what's the plan?
My plan at the moment is to find the .net types that I use most and implement visualizers for them. I'm planning on trying to get some nice ones in for TFS objects like Work Items. I'm hoping that others will use this library of visualizers and fork the code and help grow it.