Blogs C# Findings

Two great articles on customizing debugger displays with C# and Visual Studio

I’ve been working on a rather large project for the past few months (a library), and I’ve had the need to customize how the debugger displays my classes during a debug session. I found two very helpful articles from Jared Par that I wanted to share.
 

Article #1: FlattenHierarchyProxy

A problem I ran into very recently is how to simplify the creation of DebuggerTypeProxy proxy classes for objects that have several levels of inheritance (I describe the problem on StackOverflow). Briefly, when debugging an object that has one or more base classes, the base and parent properties do not show side-by-side. Base class properties and fields are under a separate expandable list. This means that you need to expand through two lists to view a property that came from the base class. More levels of clicking are required when further levels of inheritance are used.

Solution: In his article, Flattening class hierarchies when debugging C#, Jared creates a proxy class called FlattenHierarchyProxy that accomplishes what I want: parent and base class properties and members are corralled side-by-side in the debugger display. It’s a really useful class that I suggest you check out.

Side note: I’ve made several modifications and improvements on the class which I plan to publish as a new open source project. Details to follow.
 

Article #2: DebuggerDisplay attribute best practices

This article provided some helpful dos and don’ts on the usage of the DebuggeDisplay attribute. It’s a quick read, but really useful: DebuggerDisplay attribute best practices

Leave a Reply