|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Using DebuggerTypeProxy Attribute
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:
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. 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.
If DebuggerTypeProxyAttribute is used at the assembly level, the Target parameter specifies the type which the proxy will replace.
For an example of how to use this attribute along withand DebuggerTypeProxyAttribute, see .
Support for generics is limited. For C#, DebuggerTypeProxy supports only open types. An open type (also called an unconstructed type) is a generic type that has not been instantiated with arguments for its type parameters. Closed types (also called constructed types) are not supported.
The syntax for an open type looks like this:
If you use a generic type as a target in DebuggerTypeProxy, you must use this syntax. The DebuggerTypeProxy mechanism infers the type parameters for you.
For more information on open and closed types in C# see the, section 20.5.2 Open and closed types.
Visual Basic does not have open type syntax, so you cannot do the same thing in Visual Basic. Instead, you must use a string representation of the open type name.