DebuggerTypeProxy attribute - pdejonghe/DebuggerAttributesConsole GitHub Wiki
DebuggerTypeProxy attribute on Microsoft Docs
DebuggerTypeProxyAttribute specifies a proxy, or stand-in, for a type and changes the way the type is displayed in debugger windows. When you view a variable that has a proxy, the proxy stands in for the original type in the display. The debugger variable window displays only the public members of the proxy type. Private members are not displayed.
This attribute can be applied to:
- Structures
- Classes
- Assemblies
A type proxy class must have a constructor that takes an argument of the type that the proxy will replace. The debugger creates a new instance of the type proxy class every time it needs to display a variable of the target type. This can have performance implications. As a result, you should not do any more work in the constructor than absolutely necessary.
To minimize performance penalties, the expression evaluator does not examine the attributes on the display proxy of the type unless the type is expanded by the user clicking the + symbol in the debugger window or by the use of DebuggerBrowsableAttribute. Therefore, you should not place attributes on the display type itself. Attributes can and should be used in the body of the display type.
It is a good idea for the type proxy to be a private nested class within the class that the attribute targets. This allows it to access internal members easily.
DebuggerTypeProxyAttribute can be inherited, so if a type proxy is specified on a base class it will apply to any derived classes, unless those derived classes specify their own type proxy.
If DebuggerTypeProxyAttribute is used at the assembly level, the Target parameter specifies the type which the proxy will replace.