This is part 3/17 of my Exploring the .NET CoreFX series.
System.Collections.Immutable uses a number of attributes to make it more debugger-friendly. Here are the key attributes:
DebuggerStepThrough
Occasionally a method is so simple that it doesn’t make sense to have the debugger step into it. The System.Diagnostics.DebuggerStepThroughAttribute instructs the debugger to step through the code instead of stepping into the code.
Here is an example from System.Collections.Immutable:
|
|
DebuggerBrowsable
The System.Diagnostics.DebuggerBrowsableAttribute determines if and how a member is displayed in the debugger variable windows.
Here are a few examples from System.Collections.Immutable:
|
|
DebuggerDisplay
The System.Diagnostics.DebuggerDisplayAttribute controls how a class or field is displayed in the debugger variable windows. For example, if you were writing a class to represent a complex number, you could use the DebuggerDisplay attribute to render the complex number as (a, b) or even a + bi.
Here are a few examples from System.Collections.Immutable:
|
|
|
|
DebuggerTypeProxy
The System.Diagnostics.DebuggerTypeProxyAttribute allows the developer to specify a display proxy for a type, allowing the developer to completely tailor the view for the type.
Here is an example from System.Collections.Immutable:
|
|
Recommendations
- Judiciously use
DebuggerStepThrough
,DebuggerBrowsable
,DebuggerDisplay
, andDebuggerTypeProxy
to make your code more debugger-friendly.