Customizing Displays in the Debugger for System Types

Published 28 September 07 04:04 PM

We've heard feedback from several customers regarding the way certain types are displayed in the Debugger.  Many of the displays exist to maintain the user experience between versions of Visual Studio.  We constantly evaluate if this is the correct choice for a given version of the product. 

Starting with VS2008, you don't have to wait for us any longer.  In VS2008, VB added full support for many of the debugging features it lacked compared to C# in 2005.  In particular we've added full support for the DebuggerDisplayAttribute

By attributing a class or member with this attribute you can control how it is displayed in the debugger.  For each column (name, value and type) you can provide an alternate string or expression to display. 

The best part about this attribute is you can target types that exist in different libraries.  You don't even need the source for them.  One of the members in the Type field which species the target type.  Customizing a type in a separate library requires slightly more work than customizing a type you have the source for.  For a source project you can just apply the attribute directly to the type or member and it will display.  For a type in another library you need to do the following.

  • Define a class library and include all of the DebuggerDisplayAttribute you want.  Make sure to apply the attributes to the assembly and specify the Type member.  Ex.
<Assembly: DebuggerDisplay("{ToString}", Target:=GetType(Guid))>
  • Place the built library under the folder "Visual Studio 2008\Visualizers" which is under your my documents folder. 

After doing this any Guid type will now show up as the actual Guid String ("10f3c4eb-7c0f-41b1-ae83-8838ff2f4f70") instead of {System.Guid}

Jared http://blogs.msdn.com/jaredpar/

by VBTeam

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Techy News Blog » Customizing Displays in the Debugger for System Types said on September 28, 2007 7:14 PM:

PingBack from http://www.artofbam.com/wordpress/?p=3780

# Anthony D. Green, MCPD said on September 29, 2007 1:18 AM:

You just made me the happiest Visual Basic developer on earth... Guid.Empty is dead - long live Guid.ToString()!

# Bob said on October 15, 2007 11:36 AM:

It would be nice to have the VB and C# development environments (refactoring, debugging, compile and link) have the same features.  Batch build in VB would be a great addition.

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

This Blog

Syndication

Page view tracker