DebuggerTypeProxyAttribute Constructors

Definition

Initializes a new instance of the DebuggerTypeProxyAttribute class using the type of the proxy.

Overloads

DebuggerTypeProxyAttribute(String)

Initializes a new instance of the DebuggerTypeProxyAttribute class using the type name of the proxy.

DebuggerTypeProxyAttribute(Type)

Initializes a new instance of the DebuggerTypeProxyAttribute class using the type of the proxy.

DebuggerTypeProxyAttribute(String)

Source:
DebuggerTypeProxyAttribute.cs
Source:
DebuggerTypeProxyAttribute.cs
Source:
DebuggerTypeProxyAttribute.cs

Initializes a new instance of the DebuggerTypeProxyAttribute class using the type name of the proxy.

C#
public DebuggerTypeProxyAttribute(string typeName);

Parameters

typeName
String

The type name of the proxy type.

Remarks

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.

Applies to

.NET 10 ja muut versiot
Tuote Versiot
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

DebuggerTypeProxyAttribute(Type)

Source:
DebuggerTypeProxyAttribute.cs
Source:
DebuggerTypeProxyAttribute.cs
Source:
DebuggerTypeProxyAttribute.cs

Initializes a new instance of the DebuggerTypeProxyAttribute class using the type of the proxy.

C#
public DebuggerTypeProxyAttribute(Type type);

Parameters

type
Type

The proxy type.

Exceptions

type is null.

Examples

The following code example shows the use of the DebuggerTypeProxyAttribute(Type) constructor to specify a debugger display proxy. This code example is part of a larger example provided for the DebuggerDisplayAttribute class.

C#
[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;
            }
        }
    }
}

Remarks

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.

Applies to

.NET 10 ja muut versiot
Tuote Versiot
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0