Change The Display Of A Type In The Debugger

Keyvan Nayyeri has a great tip for how to control the display of a type in the various debugger windows using a DebuggerTypeProxy attribute.  His post includes screenshots with this in use.

This is an attribute you can apply to a class, assembly, or struct to specify another class to examine within a debugger window. 

You still get access to the raw view of the original type, just in case some other developer plays a practical joke on you by specifying a DebuggerTypeProxy that displays the value of every field as being 42.

What others have said

Requesting Gravatar... Alexander Groß Oct 04, 2006 9:48 AM
# re: Change The Display Of A Type In The Debugger
I also found the DebuggerDisplayAttribute very useful as one doesn't have to override the ToString() method to display summaries of the actual object being watched.
Requesting Gravatar... Keyvan Nayyeri Oct 04, 2006 12:36 PM
# re: Change The Display Of A Type In The Debugger
I set my fields to "Hock" when want to create a proxy class for others :-P
Requesting Gravatar... Jason Haley Oct 06, 2006 5:44 PM
# Interesting Finds: October 5
Requesting Gravatar... lb Oct 06, 2006 8:57 PM
# re: Change The Display Of A Type In The Debugger
>just in case some other developer plays a
>practical joke on you by specifying a
>DebuggerTypeProxy that displays the value of
>every field as being 42.

must be a wacky old time at VelocIT!
Requesting Gravatar... Haacked Oct 06, 2006 11:26 PM
# re: Change The Display Of A Type In The Debugger
It sure is! You never know *what* is going to happen.

What do you have to say?

(will show your gravatar)
Please add 3 and 4 and type the answer here: