DebuggerBrowsable is one of the productive features in .Net that can improve your productivity and it allows you to customize your debugger. Developers need to do a lot of debugging and when they need to hide some of the properties from the debugger or they want to open in expanded mode, DebuggerBrowsable is really helpful. This is quite helpful in improving productivity.
To use the preceding attributes you need to use the System.Diagnostics
namespace. If you want to customize the view on the debugger window for any properties during debugging you can easily do that using DebuggerBrowsable
attributes. You can apply DebuggerBrowsable
attributes for any properties, fields or for Indexer. The DebuggerBrowsable attributes constructor takes DebuggerBrowsableState as an argument. DebuggerBrowsableState is used to provide the instruction to the debugger of how to display it in the debugger window.
We have the following three states for DebuggerBrowsable attributes.
· Never indicates that the member is not displayed in the data window. For example, using this value for the DebuggerBrowsableAttribute on a field removes the field from the hierarchy; the field is not displayed when you expand the enclosing type by clicking the plus sign (+) for the type instance.
· Collapsed indicates that the member is displayed but not expanded by default. This is the default behavior.
· RootHidden indicates that the member itself is not shown, but its constituent objects are displayed if it is an array or collection.