« TestDriven.NET Keyboard Bindings for Vis... | Main | Adding Tabs to Internet Explorer (IE) an... »

I didn't realize this when I did my generic IFormattableObject implementation last week, but this week finds me writing a chapter on Debugging for an ASP.NET 2.0 book.

I was checking out the DebuggerDisplayAttribute and realized that it uses a similar format string style as my stuff. (Of course, my stuff isn't new, languages like Ruby and others have done it for years).

Anyway, the point was that I had been wondering if my idea "fit" into the world of .NET, but the syntax of this DebuggerDisplay attribute left me feeling more justified for my work. It's interesting though, that they are offering this attribute, when I always used ToString to do the same basic thing in the debugger. So, in a Whidbey world of DebuggerDisplayAttribute, what's ToString() for? I guess just Console.WriteLine(myObject)?

UPDATE: The "TracePoint" syntax in the VS 2005 Debugger is the same.
For example: {i.FirstName} Function: $FUNCTION, Thread: $TID $TNAME
prints out the variable i's property FirstName as well as some psuedo-variables like the current function, the Thread ID and Thread Name

Syntax Description
[DebuggerDisplay(
  "{_forename} {_surname}")]
Uses the private _forename and _surname members
[DebuggerDisplay(
  "Employee- {ToString()}")]
The ToString method is called to provide the textual representation to be displayed as the value of the object
[DebuggerDisplay("Employee
  ( {Forename} {(_wizard) ?
  \"Is a Wizard\" : \"Is 
  \"Is not a Wizard\" } )")]
An expression is evaluated in order to provide a differing representation to the user based on the value of a flag

Now playing: Kevin Lyttle - Turn Me On



Friday, February 04, 2005 3:21:41 PM (Pacific Standard Time, UTC-08:00)
The DebuggerDisplay attribute will for sure be very popular, but I wonder if it'll work with obfuscated code in the case of private members. Since you seem to be looking into this topic, have you tried that ? Maybe obfuscation tools will have to start checking and updating some of those attributes too.
Sergio Pereira
Friday, February 04, 2005 3:55:45 PM (Pacific Standard Time, UTC-08:00)
I don't get your point. This attribute is for interactive debuggers only, in debug builds only. You wouldn't be interactively debugging an obfuscated debug build, so that would never come up.
Scott Hanselman
Friday, February 04, 2005 4:07:30 PM (Pacific Standard Time, UTC-08:00)
I'm guessing the the DebuggerDisplayAttribute adds something to the assembly. Including the formatting strings like "{_forename}". I don't think Sergio was concerned about being able to debug a release assembly as much as he would prefer to hide or at least obfuscate the name of the field in the assembly...even in the formatting string.

If DebuggerDisplayAttribute emits nothing in the release build or only adds the information to the debugger information file (pdb), then there should be no problem. For example, if I loaded the release assembly in Reflector, I should not be able to find anything generated by the DebuggerDisplayAttribute in a release build.
Andy Miller
Friday, February 04, 2005 8:59:10 PM (Pacific Standard Time, UTC-08:00)
I, for one, am extremely glad that there is now an attribute that will allow you to specify how your instances are shown in the debugger. I read a little on how to do this in VS2003, and it looks like you have to edit a text file somewhere in the program files tree. And you would have to do that on each machine. I'm glad that this made it in.

- Joshua
Friday, February 04, 2005 9:58:16 PM (Pacific Standard Time, UTC-08:00)
Andy, I was actually not concerned about the format string exposure. Maybe I understood the DebuggerDisplayAttribute incorrectly but I was thinking that if I put such attribute in one of my classes and release the assembly, then someone else using this release build and debugging his own code that uses one object of my class would be able to see the formatted text in the debugger windows, even without my debug build. If the DebuggerDisplayAttribute is only considered in the debug build, then my previous comment indeed made no sense. Sorry for the confusion, Scott.
Sergio Pereira
Comments are closed.

Contact

Sponsors

Hosting By

Hot Topics

Tags

Calendar

<November 2009>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

Archives

November, 2009 (2)
October, 2009 (19)
September, 2009 (11)
August, 2009 (12)
July, 2009 (21)
June, 2009 (26)
May, 2009 (16)
April, 2009 (13)
March, 2009 (17)
February, 2009 (17)
January, 2009 (18)
December, 2008 (32)
November, 2008 (17)
October, 2008 (22)
September, 2008 (16)
August, 2008 (14)
July, 2008 (25)
June, 2008 (19)
May, 2008 (17)
April, 2008 (17)
March, 2008 (26)
February, 2008 (21)
January, 2008 (28)
December, 2007 (19)
November, 2007 (17)
October, 2007 (31)
September, 2007 (39)
August, 2007 (37)
July, 2007 (43)
June, 2007 (37)
May, 2007 (32)
April, 2007 (38)
March, 2007 (29)
February, 2007 (46)
January, 2007 (31)
December, 2006 (27)
November, 2006 (31)
October, 2006 (32)
September, 2006 (39)
August, 2006 (34)
July, 2006 (40)
June, 2006 (18)
May, 2006 (31)
April, 2006 (34)
March, 2006 (30)
February, 2006 (38)
January, 2006 (44)
December, 2005 (19)
November, 2005 (34)
October, 2005 (24)
September, 2005 (37)
August, 2005 (20)
July, 2005 (24)
June, 2005 (33)
May, 2005 (16)
April, 2005 (22)
March, 2005 (34)
February, 2005 (15)
January, 2005 (37)
December, 2004 (28)
November, 2004 (30)
October, 2004 (34)
September, 2004 (22)
August, 2004 (34)
July, 2004 (18)
June, 2004 (64)
May, 2004 (49)
April, 2004 (21)
March, 2004 (29)
February, 2004 (29)
January, 2004 (36)
December, 2003 (25)
November, 2003 (24)
October, 2003 (59)
September, 2003 (42)
August, 2003 (24)
July, 2003 (44)
June, 2003 (29)
May, 2003 (21)
April, 2003 (30)
March, 2003 (27)
February, 2003 (47)
January, 2003 (50)
December, 2002 (31)
November, 2002 (38)
October, 2002 (44)
September, 2002 (15)
May, 2002 (2)
April, 2002 (4)

Google Ads