.NET Framework Class Library
DebuggerTypeProxyAttribute Class

Specifies the display proxy for a type.

Inheritance Hierarchy
SystemObject
   SystemAttribute
    System.DiagnosticsDebuggerTypeProxyAttribute

Namespace:   System.Diagnostics
Assembly:  mscorlib (in mscorlib.dll)
Syntax
<[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_0_0_0%]([%$TOPIC/2fasz3yf_en-us_VS_110_2_0_0_0_1%].Assembly Or [%$TOPIC/2fasz3yf_en-us_VS_110_2_0_0_0_2%].Class Or [%$TOPIC/2fasz3yf_en-us_VS_110_2_0_0_0_3%].Struct, AllowMultiple := True)> _
<[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_0_0_4%](True)> _
Public NotInheritable Class DebuggerTypeProxyAttribute _
	Inherits [%$TOPIC/2fasz3yf_en-us_VS_110_2_0_0_0_5%]
[[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_1_0_0%]([%$TOPIC/2fasz3yf_en-us_VS_110_2_0_1_0_1%].Assembly|[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_1_0_2%].Class|[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_1_0_3%].Struct, AllowMultiple = true)]
[[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_1_0_4%](true)]
public sealed class DebuggerTypeProxyAttribute : [%$TOPIC/2fasz3yf_en-us_VS_110_2_0_1_0_5%]
[[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_2_0_0%]([%$TOPIC/2fasz3yf_en-us_VS_110_2_0_2_0_1%]::Assembly|[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_2_0_2%]::Class|[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_2_0_3%]::Struct, AllowMultiple = true)]
[[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_2_0_4%](true)]
public ref class DebuggerTypeProxyAttribute sealed : public [%$TOPIC/2fasz3yf_en-us_VS_110_2_0_2_0_5%]
[<[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_3_0_0%]>]
[<[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_3_0_1%]([%$TOPIC/2fasz3yf_en-us_VS_110_2_0_3_0_2%].Assembly|[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_3_0_3%].Class|[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_3_0_4%].Struct, AllowMultiple = true)>]
[<[%$TOPIC/2fasz3yf_en-us_VS_110_2_0_3_0_5%](true)>]
type DebuggerTypeProxyAttribute =  
    class 
        inherit [%$TOPIC/2fasz3yf_en-us_VS_110_2_0_3_0_6%] 
    end

The DebuggerTypeProxyAttribute type exposes the following members.

Constructors
  NameDescription
Public method Supported by Portable Class Library Supported in .NET for Windows Store apps DebuggerTypeProxyAttribute(String)Initializes a new instance of the DebuggerTypeProxyAttribute class using the type name of the proxy.
Public method Supported by Portable Class Library Supported in .NET for Windows Store apps DebuggerTypeProxyAttribute(Type)Initializes a new instance of the DebuggerTypeProxyAttribute class using the type of the proxy.
Top
Properties
  NameDescription
Public property Supported by Portable Class Library Supported in .NET for Windows Store apps ProxyTypeNameGets the type name of the proxy type.
Public property Supported by Portable Class Library Supported in .NET for Windows Store apps TargetGets or sets the target type for the attribute.
Public property Supported by Portable Class Library Supported in .NET for Windows Store apps TargetTypeNameGets or sets the name of the target type.
Public property TypeIdWhen implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)
Top
Methods
  NameDescription
Public method Supported by Portable Class Library Supported in .NET for Windows Store apps EqualsInfrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Public method Supported by Portable Class Library Supported in .NET for Windows Store apps GetHashCodeReturns the hash code for this instance. (Inherited from Attribute.)
Public method Supported by Portable Class Library Supported in .NET for Windows Store apps GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method IsDefaultAttributeWhen overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
Public method MatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Public method Supported by Portable Class Library Supported in .NET for Windows Store apps ToStringReturns a string that represents the current object. (Inherited from Object.)
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implemetation Private method _AttributeGetIDsOfNamesMaps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetation Private method _AttributeGetTypeInfoRetrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)
Explicit interface implemetation Private method _AttributeGetTypeInfoCountRetrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetation Private method _AttributeInvokeProvides access to properties and methods exposed by an object. (Inherited from Attribute.)
Top
Remarks

Note   Use this attribute when you need to significantly and fundamentally change the debugging view of a type, but not change the type itself.

The DebuggerTypeProxyAttribute attribute is used to specify a display proxy for a type, allowing a developer to tailor the view for the type. This attribute can be used at the assembly level as well, in which case the Target property specifies the type for which the proxy will be used. In general, this attribute specifies a private nested type that occurs within the type to which the attribute is applied. An expression evaluator that supports type viewers checks for this attribute when a type is displayed. If the attribute is found, the expression evaluator substitutes the display proxy type for the type the attribute is applied to.

When the DebuggerBrowsableAttribute is present, the debugger variable window displays only the public members of the proxy type. Private members are not displayed. The behavior of the data window is not changed by attribute-enhanced views.

To avoid unnecessary performance penalties, expression evaluators should not examine the attributes on the display proxy of the type unless the type is expanded, either through the user clicking the plus sign (+) next to the type in a data window, or through the application of the DebuggerBrowsableAttribute attribute. Therefore, it is recommended that no attributes be applied to the display type. Attributes can and should be applied within the body of the display type.

Examples

The following code example shows the use of the DebuggerTypeProxyAttribute to specify a private nested type to be used as a debugger display proxy. This code example is part of a larger example provided for the DebuggerDisplayAttribute class.

<DebuggerDisplay("Count = {Count}"), DebuggerTypeProxy(GetType(MyHashtable.HashtableDebugView))> _
Class MyHashtable
    Inherits Hashtable
    Private Const TestString As String = "This should not appear in the debug window." 

    Friend Class HashtableDebugView
        Private hashtable As Hashtable
        Public Shared TestString As String = "This should appear in the debug window." 

        Public Sub New(ByVal hashtable As Hashtable)
            Me.hashtable = hashtable
        End Sub 'New

        <DebuggerBrowsable(DebuggerBrowsableState.RootHidden)> _
        ReadOnly Property Keys as KeyValuePairs()
            Get 
                Dim nkeys(hashtable.Count) as KeyValuePairs

                Dim i as Integer = 0
                For Each key As Object In hashtable.Keys
                    nkeys(i) = New KeyValuePairs(hashtable, key, hashtable(key))
                    i = i + 1
                Next 
                Return nkeys
            End Get 
        End Property 

    End Class 'HashtableDebugView
End Class 'MyHashtable
[DebuggerTypeProxy(typeof(HashtableDebugView))]
class MyHashtable : Hashtable
{
    private const string TestString = "This should not appear in the debug window.";

    internal class HashtableDebugView
    {
        private Hashtable hashtable;
        public const string TestString = "This should appear in the debug window.";
        public HashtableDebugView(Hashtable hashtable)
        {
            this.hashtable = hashtable;
        }

        [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
        public KeyValuePairs[] Keys
        {
            get
            {
                KeyValuePairs[] keys = new KeyValuePairs[hashtable.Count];

                int i = 0;
                foreach(object key in hashtable.Keys)
                {
                    keys[i] = new KeyValuePairs(hashtable, key, hashtable[key]);
                    i++;
                }
                return keys;
            }
        }
    }
}
[DebuggerTypeProxy(HashtableDebugView::typeid)]
ref class MyHashtable : Hashtable
{
private:
    static const String^ TestString = "This should not appear in the debug window.";

internal:
    ref class HashtableDebugView
    {
    private:
        Hashtable^ hashtable;
    public:
        static const String^ TestString = "This should appear in the debug window.";
        HashtableDebugView(Hashtable^ hashtable)
        {
            this->hashtable = hashtable;
        }

        [DebuggerBrowsable(DebuggerBrowsableState::RootHidden)]
        property array<KeyValuePairs^>^ Keys
        {
            array<KeyValuePairs^>^ get()
            {
                array<KeyValuePairs^>^ keys = gcnew array<KeyValuePairs^>(hashtable->Count);

                IEnumerator^ ie = hashtable->Keys->GetEnumerator();
                int i = 0;
                Object^ key;
                while (ie->MoveNext())
                {
                    key = ie->Current;
                    keys[i] = gcnew KeyValuePairs(hashtable, key, hashtable[key]);
                    i++;
                }
                return keys;
            }
        }
    };
};
Version Information

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1
Platforms

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.