Skip to content

Commit c7873a1

Browse files
committed
Update article on DebuggerDisplay
1 parent dcc5dd9 commit c7873a1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

docs/debugger/using-the-debuggerdisplay-attribute.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Display custom info using DebuggerDisplay
33
description: Use an instance of DebuggerDisplayAttribute to control how an object, property, or field is displayed in the debugger variable windows.
4-
ms.date: 04/22/2022
4+
ms.date: 04/15/2025
55
ms.topic: how-to
66
helpviewer_keywords:
77
- attributes, debugger
@@ -42,18 +42,19 @@ The following table shows some possible uses of the `DebuggerDisplay` attribute
4242
|`Name`, `Type`|These parameters affect the **Name** and **Type** columns of the variable windows. (They can be set to strings using the same syntax as the constructor.) Overusing these parameters, or using them incorrectly, can cause confusing output.|
4343
|`Target`, `TargetTypeName`|Specifies the target type when the attribute is used at the assembly level.|
4444

45-
The autoexp.cs file uses the DebuggerDisplay attribute at the assembly level. The autoexp.cs file determines the default expansions that Visual Studio uses for .NET objects. You can examine the autoexp.cs file for examples of how to use the DebuggerDisplay attribute, or you can modify and compile the autoexp.cs file to change the default expansions. Be sure to back up the autoexp.cs file before you modify it.
45+
The *autoexp.cs* file uses the DebuggerDisplay attribute at the assembly level. The *autoexp.cs* file determines the default expansions that Visual Studio uses for .NET objects. You can examine the *autoexp.cs* file for examples of how to use the DebuggerDisplay attribute, or you can modify and compile the autoexp.cs file to change the default expansions. Be sure to back up the *autoexp.cs* file before you modify it.
4646

47-
To build autoexp.cs, open up a Developer Command Prompt for VS2015, and run the following commands
47+
To build *autoexp.cs*, open up a Developer Command Prompt for VS2015, and run the following commands
4848

4949
```cmd
5050
cd <directory containing autoexp.cs>
5151
csc /t:library autoexp.cs
5252
```
5353

54-
The changes to autoexp.dll will be picked up in the next debug session.
54+
The changes to *autoexp.dll* will be picked up in the next debug session.
5555

5656
## Using Expressions in DebuggerDisplay
57+
5758
Although you can use a general expression between the braces in a DebuggerDisplay attribute, this practice is not recommended.
5859

5960
A general expression in DebuggerDisplay has implicit access to the `this` pointer for the current instance of the target type only. The expression has no access to aliases, locals, or pointers. If the expression references properties, attributes on those properties are not processed. For example, the C# code `[DebuggerDisplay("Object {count - 2}")]` would display `Object 6` if the field `count` was 8.
@@ -84,9 +85,10 @@ public sealed class MyClass
8485
}
8586
```
8687

87-
The ",nq" suffix tells the expression evaluator to remove the quotes when displaying the final value (nq = no quotes).
88+
The ",nq" suffix tells the expression evaluator to remove the quotes when displaying the final value (nq = no quotes). For more information on formatters, see [Format specifiers in C#](../debugger/format-specifiers-in-csharp.md).
8889

8990
## Example
91+
9092
The following code example shows how to use `DebuggerDisplay`, together with `DebuggerBrowsable` and `DebuggerTypeProxy`. When viewed in a debugger variables window, such as the **Watch** window, it produces an expansion that looks like this:
9193

9294
|**Name**|**Value**|**Type**|

0 commit comments

Comments
 (0)