In the category of make-your-daily-life-better, Laura Petersen showed two wonderful extensions to the VS debugger.
First, the DTE object that deserves much attention. DTE.Debugger gives you programmatic (macro (VB)) access to everything you can do with the Visual Studio IDE debugger. Besides the properties on DTE.Debugger, look for properties on DTE.Properties("Debugger", "General").
Second, if you're frustrated by the noisy views the debugger shows for your types, and are ready to move beyond overriding ToString (and hoping the debugger picks it up), you can define a custom debugger view by adding any / all of the following attributes from System.Diagnostics to your class:
- DebuggerDisplayAttribute: summary view using a simple template language
- DebuggerBrowsableAttribute: view of fields
- DebuggerTypeProxyAttribute: a proxy to display instead
Third (and yes, I can count), if you'd like to create a visualizer for a complex (or just large) value, you can create a custom visualizer (which I tried but, as advertised, it's a bit more complicated):
Create a visualizer:
- Create new class library
- Add a reference to Microsoft.VisualStudio.Debugger.Visualizers.dll [In my install, this is in "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies\"]
- Add new DebuggerVisualizer item to the project.
- Add code inside the Show method.
- Build and copy the visualizer dll to your VS documents Visualizers folder.
To use the visualizer:
- Add references to both the Microsoft.VisualStudio.Debugger.Visualizers.dll and the visualizer dll.
- Make the to-be-visualized type Serializable (if not already)
- Add the DebuggerVisualizerAttribute
Blogs:
Forum: http://social.msdn.microsoft.com/Forums/en-US/vsdebug/threads/
http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=vsxconf&DownloadId=3175
Posted
Sep 16 2008, 12:25 PM
by
jeffrey-schlimmer