Skip to Main Content
Professional Visual Studio® 2008
book

Professional Visual Studio® 2008

by Nick Randolph, David Gardner
July 2008
Intermediate to advanced content levelIntermediate to advanced
1026 pages
27h 59m
English
Wrox
Content preview from Professional Visual Studio® 2008

43.1. Attributes

This section begins by outlining a number of debugging attributes that can be applied to code to affect the way the debugger steps through it. Some of the debugging attributes can also be used to customize the appearance of your types when you hover over them in Break mode.

The debugging attribute classes are contained within the System.Diagnostics namespace. Rather than specify the full namespace for each attribute, the source code examples in this chapter assume that it has been added as an import.

43.1.1. DebuggerBrowsable

The first attribute you can apply to fields and properties that belong to a C# class is the DebuggerBrowsable attribute. Although this attribute can be applied to both C# and Visual Basic code, it is only interpreted by the C# debugger. This attribute takes a single parameter that determines how the member is displayed in the variable tree. In the following code snippet, the field Orders is set to Collapsed:

public class Customer
{
    [DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
    public List<Order> Orders;

}

Figure 43-1 (left) shows the same snippet of code with DebuggerBrowsable initially set to Collapsed (or not specified). Figure 43-1 (center) shows the same snippet with DebuggerBrowsable set to the RootHidden value, where the actual Orders item does not appear, just the contents of the collection. Finally, in Figure 43-1 (right) the Never value is used for DebuggerBrowsable, in which case the Orders member does not appear at all. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Professional Visual Studio® 2010

Professional Visual Studio® 2010

Nick Randolph, David Gardner, Michael Minutillo, Chris Anderson

Publisher Resources

ISBN: 9780470229880Purchase book