Search code examples
c#debuggingdebuggervisualizer

Visual Studio: See a MyList class, in Debug, as if it was a DataGrid


I would like to use the DebuggerTypeProxy attribute to show, in Debug, a class using Datatable.

I try to better explain what I mean.

I can tell VS to show a class using another proxy class. So if I have a list I can tell him to visualize that list after putting all the data's in a Datatable. So I can use the standard DebugVisualizer for datatables.


Solution

  • There are a few ways to provide custom debugging visualization,

    1. Use [DebuggerDisplay] attribute

      [DebuggerDisplay("Point {X}:{Y}")]

      public class Point

      { public int X {get;set;} public int Y {get;set;} }

    2. use DebuggerBrowsableDisplay attribute and set the State property to DebuggerBrowsableState.RootHidden - it will alow you to show collections like you have already pressed +

    3. DebuggerTypeProxy attribute - for any custom visualizer.

    But personally i wouldnt bother with writing a custom visualizer for the problem that you are describing - there are already debugging products that can do it for you. You can download OzCode, VS extencion that is still free in its beta and use its Reveal feature:

    http://o.oz-code.com/features#reveal

    It seems to be exactly what you need :)