You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/debugger/using-debuggertypeproxy-attribute.md
+42-39Lines changed: 42 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -21,42 +21,45 @@ ms.workload:
21
21
- "multiple"
22
22
---
23
23
# Using DebuggerTypeProxy Attribute
24
-
<xref:System.Diagnostics.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.
25
-
26
-
This attribute can be applied to:
27
-
28
-
- Structures
29
-
30
-
- Classes
31
-
32
-
- Assemblies
33
-
34
-
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.
35
-
36
-
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 <xref:System.Diagnostics.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.
37
-
38
-
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.
39
-
40
-
If <xref:System.Diagnostics.DebuggerTypeProxyAttribute> is used at the assembly level, the `Target` parameter specifies the type which the proxy will replace.
41
-
42
-
For an example of how to use this attribute along with <xref:System.Diagnostics.DebuggerDisplayAttribute> and <xref:System.Diagnostics.DebuggerTypeProxyAttribute>, see[Using the DebuggerDisplay Attribute](../debugger/using-the-debuggerdisplay-attribute.md).
43
-
44
-
## Using Generics with DebuggerTypeProxy
45
-
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.
46
-
47
-
The syntax for an open type looks like this:
48
-
49
-
`Namespace.TypeName<,>`
50
-
51
-
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.
52
-
53
-
For more information on open and closed types in C# see the [C# Language Specification](/dotnet/csharp/language-reference/language-specification), section 20.5.2 Open and closed types.
54
-
55
-
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.
56
-
57
-
`"Namespace.TypeName'2"`
58
-
59
-
## See Also
60
-
[Using the DebuggerDisplay Attribute](../debugger/using-the-debuggerdisplay-attribute.md)
61
-
[Create custom views of .managed objects](../debugger/create-custom-views-of-dot-managed-objects.md)
62
-
[Enhancing Debugging with the Debugger Display Attributes](/dotnet/framework/debug-trace-profile/enhancing-debugging-with-the-debugger-display-attributes)
24
+
25
+
<xref:System.Diagnostics.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.
26
+
27
+
This attribute can be applied to:
28
+
29
+
- Structures
30
+
- Classes
31
+
- Assemblies
32
+
33
+
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.
34
+
35
+
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 <xref:System.Diagnostics.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.
36
+
37
+
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.
38
+
39
+
<xref:System.Diagnostics.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.
40
+
41
+
If <xref:System.Diagnostics.DebuggerTypeProxyAttribute> is used at the assembly level, the `Target` parameter specifies the type which the proxy will replace.
42
+
43
+
For an example of how to use this attribute along with <xref:System.Diagnostics.DebuggerDisplayAttribute> and <xref:System.Diagnostics.DebuggerTypeProxyAttribute>, see[Using the DebuggerDisplay Attribute](../debugger/using-the-debuggerdisplay-attribute.md).
44
+
45
+
## Using Generics with DebuggerTypeProxy
46
+
47
+
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.
48
+
49
+
The syntax for an open type looks like this:
50
+
51
+
`Namespace.TypeName<,>`
52
+
53
+
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.
54
+
55
+
For more information on open and closed types in C# see the [C# Language Specification](/dotnet/csharp/language-reference/language-specification), section 20.5.2 Open and closed types.
56
+
57
+
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.
58
+
59
+
`"Namespace.TypeName'2"`
60
+
61
+
## See Also
62
+
63
+
-[Using the DebuggerDisplay Attribute](../debugger/using-the-debuggerdisplay-attribute.md)
64
+
-[Create custom views of .managed objects](../debugger/create-custom-views-of-dot-managed-objects.md)
65
+
-[Enhancing Debugging with the Debugger Display Attributes](/dotnet/framework/debug-trace-profile/enhancing-debugging-with-the-debugger-display-attributes)
0 commit comments