This past week, I had a fun time travelling to present at three .NET User Groups in Pennsylvania, thanks to INETA. Each group had requested a completely different topic, so I spoke about Ink Enabling Web Apps in Harrisburg on Tuesday, Customized Debugging in VS2005 in Bethlehem on Wednesday and 5 [Supposedly] Scary Things about .NET in Wilkes-Barre on Thursday.
I hadn't done the debugging talk in a while. It mostly focuses on Debugger Visualizers (which I was pretty excited about when I first discovered them because they enabled me to look at data objects the way *I* wanted to!). But I have found it to be a pretty narrow topic and especially at conferences, when people expect a a big bang for their buck in a session, it doesn't feel very impactful. But for a user group, it works and I was happy that Chris Waters, the leader of Lehigh Valley .NET User Group, had given me an opportunity to do it again.
In addition to the visualizers, I also talk about some of the new Debugger Display Attributes in .NET 2.0, because they too, impact the design time debugging experience for developers. I really dig showing this stuff because I really love how you can clean up the debug view.
Here's the before and after example of a collection of simple "employee" class that I created.



By default, we see all of the private variables (_firstname, _lastname) and public properties. Since the properties are merely exposing the private variables, that's totally redundant. There's also an address class within the employee object. I see two of those again (public property and private variable) and have to drill in to see the address details. When looking at just the collection, I have to look at the class names of the objects.
Using the DebuggerDisplay and DebuggerBrowsable (this one is only in C# :-( ) attributes, I can totally change how this looks!


I have used the DebuggerBrowsable attribute on the address property in the employee class to hide the root of the address object,
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public AddressClass Address
{get { return _address; }}
thereby exposing the street and city at the root level. I have hidden each of the private variables as with the _firstname shown here:
[
DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string _firstname;
I have used the DebuggerDisplay attribute on the employee class itself to display the class in a more meaningful way (lastname,firstname of employee) than just the metadata.
[
DebuggerDisplay("{_lastname}, {_firstname}")]
public class EmployeeClassFancy{...
You can get the code from my example here.