
Write a Custom Visualizer #43
Chapter 5, Debugging
|
169
HACK
HACK
#43
Write a Custom Visualizer Hack #43
View complex data types with custom visualizers in Visual Studio 2005.
Have you ever been debugging an application and decided that you need to
view the contents of a DataSet that is being shown in your Locals or Watch
window? Well, if you tried this before Visual Studio 2005, you would have
had quite a hard time actually getting to the rows and values of the data-
grid—it is no small task. You would need to go from DataSet
➝ Tables ➝
List ➝ [0] (first table in the array) ➝ Rows ➝ List ➝ [0] (row array) ➝ Item
Array. You would then see the window shown in Figure 5-33.
This view is hard to get to, hard to use, and doesn’t even include column
names.
Visualizers make this process much easier and more enjoyable. Visualizers
provide customized views of data while debugging. Instead of the normal
limitations of the debug windows, visualizers are custom Windows Forms
that can display the data in any way imaginable. If you had a type that repre-
sented an image, you could display the actual image using the visualizer,
instead of the text you would normally see in the debugger window.
When you are debugging an application, a small magnifying glass will
appear next to the variable in the debugging window if a visualizer exists for
that type. You can click on the magnifying glass to launch into the custom
visualizer ...