Search code examples
c#visual-studio-2010visual-studio-debuggingvisual-studio-extensions

Extend the Visual Studio Locals/Autos window through code


Is it possible to extend what appears in the VS Locals/Autos window through code? Like through a Visual Studio Extension? I would like to iterate through the displayed variables and manipulate how they are organized and appear.

I have read up on techniques like using AutoExp.dat and .NatVis, but would like to write code that actively re-arranges the structure of displayed items via C# code. All of our types have a similar structure, and I would like more flexibility than doing this via a massive type-specific file.

I am trying to make it simpler for people to read our generated code structures.


Solution

  • If you're talking about what displays when you mouse-over/add a watch, there's the DebuggerDisplay attribute:

    Using DebuggerDisplay Attribute

    Enhancing Debugging with the Debugger Display Attributes

    Oh, almost forgot: for more complicated debugger extensions, you can always create your own Visualizer - this is similar to what you get if you use the little magnifying glass/drop down on a variable during debugging:

    Visualizers

    CodeProject - Create a visualizer in 10 lines of code