Skip to content

Commit 2a1d70f

Browse files
committed
edits
1 parent a38a3c2 commit 2a1d70f

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

docs/debugger/autos-and-locals-windows.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ms.collection: ce-skilling-ai-copilot
1818

1919
# Inspect variables and return values in the Visual Studio debugger
2020

21-
When you try to debug an issue, you are often attempting to find out whether variables are storing the values that you expect them to have in a particular app state. Some of the most useful features of the debugger are those that allow you to inspect variables.
21+
When you try to debug an issue, you're often attempting to find out whether variables are storing the values that you expect them to have in a particular app state. Some of the most useful features of the debugger are those that allow you to inspect variables.
2222

2323
This article shows you how to inspect variables and view return values using the debugger in Visual Studio. The debugger provides several convenient ways to perform these tasks, including the following:
2424

@@ -31,7 +31,7 @@ These features are only available while debugging. To learn how to start a debug
3131
> [!NOTE]
3232
> If this is the first time that you've tried to debug code, you might want to read [Debugging for absolute beginners](../debugger/debugging-absolute-beginners.md) and [Debugging techniques and tools](../debugger/write-better-code-with-visual-studio.md) before going through this article.
3333
34-
## View data tips in the code editor
34+
## View variables in the code editor
3535

3636
Often, when debugging, you want a quick way to check property values on objects in the code editor, and the data tips are a good way to do it.
3737

@@ -51,7 +51,7 @@ For detailed information on using data tips, see [View data values in data tips]
5151
::: moniker range=">= vs-2022"
5252
## View inline return values of method calls in the code editor
5353

54-
In .NET and C++ code, you can examine return values when you step over or out of a method call, which can be useful when the return value is not stored in a local variable. A method could be used as a parameter, or as the return value of another method.
54+
In .NET and C++ code, you can examine return values when you step over or out of a method call, which can be useful when the return value isn't stored in a local variable. A method could be used as a parameter, or as the return value of another method.
5555

5656
Starting in Visual Studio 2022 version 17.12, you can view return values of method calls inline and not just in the [Autos window](#view-return-values-in-the-autos-window).
5757

@@ -66,7 +66,7 @@ With Copilot enabled, you can also get targeted assistance related to the inline
6666

6767
You can use a **Watch** window to specify a variable (or an expression) that you want to keep an eye on.
6868

69-
While debugging, right-click an object and choose **Add Watch**.
69+
While debugging, right-click an object and choose **Add Watch**. A Watch window opens.
7070

7171
::: moniker range=">= vs-2022"
7272
![Watch Window](../debugger/media/vs-2022/dbg-tour-watch-window.png "Watch window")
@@ -75,21 +75,27 @@ While debugging, right-click an object and choose **Add Watch**.
7575
![Watch Window](../debugger/media/dbg-tour-watch-window.png "Watch window")
7676
::: moniker-end
7777

78-
In this example, you have a watch set on the object, and you can see its value change as you move through the debugger. Unlike the other variable windows, the **Watch** windows always show the variables that you are watching (they're grayed out when out of scope).
78+
In this example, you've a watch set on the object, and you can see its value change as you move through the debugger. Unlike the other variable windows, the **Watch** windows always show the variables that you're watching (they're grayed out when out of scope).
7979

8080
For detailed information, see [Set a Watch using the Watch and QuickWatch Windows](../debugger/watch-and-quickwatch-windows.md).
8181

82-
## Inspect variables in the Autos and Locals windows
82+
::: moniker range=">= vs-2022"
83+
## Get AI assistance
84+
85+
If you have [Copilot](../ide/visual-studio-github-copilot-extension.md), you can get AI assistance while you're looking at variables in the Autos or Locals windows, or in data tips in the code editor. Right-click on a variable and use the **Ask Copilot** ![Screenshot of Ask Copilot button.](../debugger/media/vs-2022/debug-with-copilot-ask-copilot-button.png) button. In this scenario, Copilot already knows the context for your question, so you don't need to provide context yourself in chat. For more information, see [Debug with Copilot](../debugger/debug-with-copilot.md).
86+
::: moniker-end
87+
88+
## Inspect variables in debugger windows (Autos and Locals)
8389

84-
The **Autos** and **Locals** windows show variable values while you are debugging. The windows are only available during a debugging session. The **Autos** window shows variables used around the current statement where the debugger is paused. The **Locals** window shows variables defined in the local scope, which is usually the current function or method.
90+
The **Autos** and **Locals** windows show variable values while you're debugging. The windows are only available during a debugging session. The **Autos** window shows variables used around the current statement where the debugger is paused. The **Locals** window shows variables defined in the local scope, which is usually the current function or method.
8591

8692
- To open the **Autos** window, while debugging, select **Debug** > **Windows** > **Autos**, or press **Ctrl**+**Alt**+**V** > **A**.
8793

8894
The **Autos** window is available for C#, Visual Basic, C++, and Python code, but not for JavaScript or F#.
8995

9096
- To open the **Locals** window, while debugging, select **Debug** > **Windows** > **Locals**, or press **Alt**+**4**.
9197

92-
Arrays and objects show in the **Autos** and **Locals** windows as tree controls. Select the arrow to the left of a variable name to expand the view to show fields and properties. Here is an example of a <xref:System.IO.FileStream?displayProperty=fullName> object in the **Locals** window:
98+
Expandable arrays and objects show up in the **Autos** and **Locals** windows. Select the arrow to the left of a variable name to expand the view to show fields and properties. Here is an example of a <xref:System.IO.FileStream?displayProperty=fullName> object in the **Locals** window:
9399

94100
::: moniker range=">= vs-2022"
95101
![Screenshot of the Locals window, with file set to a System.IO.FileStream value.](../debugger/media/vs-2022/locals-filestream.png)
@@ -102,7 +108,7 @@ A red value in the **Locals** or **Autos** window means the value has changed si
102108

103109
The default numeric format in debugger windows is decimal. To change it to hexadecimal, right-click in the **Locals** or **Autos** window and select **Hexadecimal Display**. This change affects all debugger windows.
104110

105-
### Edit variable values in the Autos or Locals window
111+
## Edit variable values in the Autos or Locals window
106112

107113
To edit the values of most variables in the **Autos** or **Locals** windows, double-click the value and enter the new value.
108114

@@ -113,11 +119,11 @@ In native C++ code, you might have to qualify the context of a variable name. Fo
113119
>[!CAUTION]
114120
> Make sure you understand the consequences before you change values and expressions. Some possible issues are:
115121
>
116-
>- Evaluating some expressions can change the value of a variable or otherwise affect the state of your program. For example, evaluating `var1 = ++var2` changes the value of both `var1` and `var2`. These expressions are said to have [side effects](https://en.wikipedia.org/wiki/Side_effect_\(computer_science\)). Side effects can cause unexpected results if you are not aware of them.
122+
>- Evaluating some expressions can change the value of a variable or otherwise affect the state of your program. For example, evaluating `var1 = ++var2` changes the value of both `var1` and `var2`. These expressions are said to have [side effects](https://en.wikipedia.org/wiki/Side_effect_\(computer_science\)). Side effects can cause unexpected results if you're not aware of them.
117123
>
118124
>- Editing floating-point values can result in minor inaccuracies because of decimal-to-binary conversion of fractional components. Even a seemingly harmless edit can result in changes to some of the bits in the floating-point variable.
119125
120-
### Search in the Autos or Locals window
126+
## Search in the Autos or Locals window
121127

122128
You can search for keywords in the Name, Value, and Type columns of the **Autos** or **Locals** window using the search bar above each window. Hit ENTER or select one of the arrows to execute a search. To cancel an ongoing search, select the "x" icon in the search bar.
123129

@@ -132,7 +138,7 @@ Use the left and right arrows (Shift+F3 and F3, respectively) to navigate betwee
132138

133139
To make your search more or less thorough, use the **Search Deeper** dropdown list at the top of the **Autos** or **Locals** window to select how many levels deep you want to search into nested objects.
134140

135-
### Pin properties in the Autos or Locals window
141+
## Pin properties in the Autos or Locals window
136142

137143
> [!NOTE]
138144
> This feature is supported for .NET Core 3.0 or higher.
@@ -147,7 +153,7 @@ You can also toggle property names and filter out non-pinned properties when vie
147153

148154
![Screenshot of Toggle property names.](../debugger/media/toggle-property-names.gif "Toggle property names")
149155

150-
### Change the context for the Autos or Locals window
156+
## Change the context for the Autos or Locals window
151157

152158
You can use the **Debug Location** toolbar to select a desired function, thread, or process, which changes the context for the **Autos** and **Locals** windows.
153159

@@ -162,7 +168,7 @@ Set a breakpoint and start debugging. When the breakpoint is hit, execution paus
162168
![Screenshot of Debug Location toolbar.](../debugger/media/debuglocationtoolbar.png "Debug Location toolbar")
163169
::: moniker-end
164170

165-
### <a name="bkmk_whatvariables"></a> Language differences in the Autos window (C#, C++, Visual Basic, Python)
171+
## <a name="bkmk_whatvariables"></a> Language differences in the Autos window (C#, C++, Visual Basic, Python)
166172

167173
Different code languages display different variables in the **Autos** window.
168174

@@ -215,7 +221,7 @@ Different code languages display different variables in the **Autos** window.
215221
216222
The variable `e` is uninitialized, because the line `e = 5` has not yet been executed.
217223
218-
### View return values in the Autos window
224+
## View return values in the Autos window
219225
220226
In the following example, this C# code adds the return values of two functions:
221227
@@ -256,7 +262,7 @@ To see the return values of the `sumVars()` and `subtractVars()` method calls in
256262

257263
## Open a visualizer to inspect variables
258264

259-
While you are debugging in Visual Studio, you can view large strings or complex objects with built-in visualizers that make the data easier to inspect. For example:
265+
While you're debugging in Visual Studio, you can view large strings or complex objects with built-in visualizers that make the data easier to inspect. For example:
260266

261267
- The string visualizer shows text, XML, HTML, and JSON strings that are too long for a data tip or debugger window. It can also help you identify malformed strings. For more information, see [View strings in a string visualizer](../debugger/view-strings-visualizer.md).
262268
- The DataSet and IEnumerable visualizers show .NET collection objects in a tabular visualizer. For more information, see [Tabular visualizers in Visual Studio](../debugger/view-data-in-tabular-visualizer.md)) objects.
@@ -275,12 +281,6 @@ To open a visualizer, you must be paused during debugging. Hover over a variable
275281
![Open a string visualizer](../debugger/media/dbg-tips-string-visualizers.png "Open string visualizer")
276282
::: moniker-end
277283

278-
::: moniker range=">= vs-2022"
279-
## Get AI assistance
280-
281-
If you have [Copilot](../ide/visual-studio-github-copilot-extension.md), you can get AI assistance while you're looking at variables in the Autos or Locals windows, or in data tips. Right-click on a variable and use the **Ask Copilot** ![Screenshot of Ask Copilot button.](../debugger/media/vs-2022/debug-with-copilot-ask-copilot-button.png) button. In this scenario, Copilot already knows the context for your question, so you don't need to provide context yourself in chat. For more information, see [Debug with Copilot](../debugger/debug-with-copilot.md).
282-
::: moniker-end
283-
284284
## Related content
285285

286286
- [What is debugging?](../debugger/what-is-debugging.md)

0 commit comments

Comments
 (0)