Customizing Debugging Session in .NET: Part II

(The source code is attached.)

Continuing to my previous article on "Customizing Debugging Session in .NET: Part I", we can further control how properties and fields appear in our debugger window. Based on our debugging requirements, we can show and hide properties in our debugging session using one of the useful attributes named DebuggerBrowsableAttribute.

Let's proceed to see a debug window for one of the code snippets:

debug window

In the above image you will see that by default the list of Awards is not in expanded form. In order to view the values of the awards, one needs to expand that forcibly either by hovering the mouse or by clicking on the plus symbol, that will result in the following screenshot:
 
Expand plus symbol

Hiding unwanted properties
How to hide unwanted properties during a debugging session? What if a developer is not interested in viewing the employee's branch?

Well, that unwanted property can be hidden by setting DebuggerBrowsableState to Never as shown below:
 
DebuggerBrowsableState

Now let's run the code and check whether it is hidden:
 
run the code

As expected, you get a debugger window as above with the Branch property hidden. Great! Let's move to the next question.

Expanding a list of awards automatically

Is there any way to expand a list of awards automatically in my debugger window?

Yes, we can. Using the DebuggerBrowsableState as RootHidden is shown below:
 
RootHidden

On debugging the application, you will see the list of awards in an expanded state as in the following:
 
debugging the application

I hope you enjoyed playing with your favorite debugger window.

Previous article : Customizing Debugging Session in .NET - Part I

Next Recommended Readings