Creating Debugger Visualizers with Visual Studio 2005 One of the very many cool new features in Visual Studio 2005 is the debugger visualizer. With debugger visualizers, developers are able to define what information they would like to see about a particular .NET class or even one of their own classes during debug mode. And as the name suggests, you can also choose how you would like to visualize these details. | " | The real beauty of debugger visualizers is that you can write your own. You can create debugger visualizers to display information about .NET Framework classes or your own custom classes.
| " |
Visual Studio 2005 has some pre-existing visualizers that you will discover during debug mode. You can access the visualizers by using a dropdown list on the left side of the new DataTips between the selection and its value. (Note that prior to the November Community Technical Preview (aka CTP), the dropdown was on the right. You will find the new position much more convenient.) For example, if you point to a string object in Debug mode as in Figure 1, or even an actual string as in Figure 2, you will have access to three debugger visualizers: Text, XML or HTML.  Figure 1: You can access debugger visualizers from a drop down in the datatips. Here is a debugger visualizer for an object. Figure 2: These visualizers are also available for raw string data in your code.You can also access visualizers through the Watch windows. Figure 3 shows the DataTip's Watch window where you can see the _stringvalue property of a StringBuilder object. When you select the XML visualizer, you will get a better view of the XML-formatted string, demonstrated in Figure 4.  Figure 3: Debugger visualizers are also available in the watch windows as seen with this m_stringValue property of a StringBuilder object. Figure 4: An XML visualizer displays XML in a format that is perfectly readable.Another handy visualizer that Microsoft has already written and included with the Beta1 version of Visual Studio 2005 is for DataTables and for DataSets. Something that surely many developers have considered?this visualizer presents a quick way to see the contents of a DataTable. Though they are named "DataSet visualizer" and "DataTable visualizer," they present the same UI. These two visualizers are read-only. The screenshots in a DataSet visualizer in Figure 5 and Figure 6 show how you can select the various DataTables within a DataSet to view.  Figure 5: Microsoft has also provided pre-written visualizers for DataSets and DataTables. Figure 6: The DataSet and DataTable visualizer shows a grid view of the actual data. You can access all DataTables in a DataSet through the DataSet visualizer's interface.Look for more "out-of-the-box" visualizers in future releases of Visual Studio 2005. | & | | 
By: Julia Lerman Julie Lerman is a Microsoft MVP, .NET mentor and consultant who lives in the hills of Vermont. You can find Julie presenting on data access and other topics at user groups and conferences around the world. Julie blogs at thedatafarm.com/blog and is the author of the highly acclaimed Programming Entity Framework (O’Reilly Media). Follow Julie on twitter at julielermanvt.
jlerman@thedatafarm.com | Fast Facts | | Debug info is no longer limited to what comes in the box with Visual Studio .NET. Visual Studio 2005's new debugger visualizers enable you to inspect classes in more useful and complex ways, You can write your own visualizer for .NET classes or custom classes to see the information that you find useful while debugging. In addition, Microsoft has written a handful of helpful visualizers to get you started. | |
|