Debugging Visualizers in Visual Studio 2005
One of the cool new features of Visual Studio 2005 is the Debugger Visualizer, which provides an alertnate way to view an object in the VS 2005 debugger. What's especially cool about these little gems is that not only does Visual Studio ship with a number of buit-in visualizers for viewing long strings, XML, HTML, images, and so on, but also provides a mechanism for developers to be able to create their own visualizers and plug them into Visual Studio. (See Creating a Debugger Visualizer Using Visual Studio for more information.)
Yesterday, Scott Guthrie posted a blog entry about free debugger visualizers released by various folks in the community, such as an XML visualizer, and a regular expression visualizer. What really caught my eye, though, was K. Scott Allen's control hierarchy visualizer. With this visualizer you can view the control hierarchy rooted at the control whose little magnifying glass icon you click to load the visualizer.
Since Scott kindly gives the source code for his visualizer, I was able to poke around and add a new feature: in addition to seeing the controls in the hierarchy I also added nodes for the controls' properties (and their values). This required just a few lines of code to perform the reflection on each control in the hierarchy. (FYI, it takes a couple seconds to load up on pages with rather large control hierarchies...) Plus I added a little color and icons, just to spruce things up a tad. :-)
You can download my additions to Scott's visualizer: WebVisualizers.zip. To quote from Scott's blog entry:
To install the a visualizer you have to build the source code. You can build with Visual Studio, or from the command line msbuild OdeToCode.WebVisualizers.csproj, assuming msbuild.exe is in the path. Copy the .dll from underneath the bin directory into MyDocuments\Visual Studio 2005\Visualizers. VS will automatically load the assembly when debugging, and inspect the metadata inside to know what types to visualize. Note: custom visualizers won't load for a web site running at less than full trust.