While we wait for Whidbey visualizers...
Note: this entry has moved.
I'm as excited as almost everybody else with the ability to write custom visualizers in managed code, so that at debug-time I have a better experience and interaction with variables and their data. However, there're a couple things you can do right now to improve the debugging experience. Here's my favorite list of "tips":
1 - Download
VSTweak: this powertoy enables a sort of visualizer for your data.
Let me explain: by default, when you set a breakpoint and
hover over a variable, you get the class name displayed. Not
too helpful, right? So you have to dig in the Locals, Autos
or Watch windows and look at all the instance members, which
you probable don't care at all except for only a couple of
them, which you have to locate.
Well, VSTweak has a
Debugger Editor
that allows you to change the string representation of your
classes at debug-time, that is, the value displayed in the
tooltip AND the debug windows, which is the class name yb
default, as we said. This feature is located in the
Debug Editor tab of the tool. You can look at
how the display for most built-in types is laid out, and
learn the syntaxis from them. For example, a
Rectangle representation is defined as follows:
2 - Getting unescaped strings: quite often you build
XML/HTML or whatever with a StringBuilder or by
some other means. At debugging-time, if you ask for any
string variable value you get it escaped, which isn't very
useful. You can't copy/paste to a text editor to save to a
file and check how it looks like, for example. A trick I use
all the time is issuing the following command in the Command
Window - Inmediate: