Skip to content

Commit 80e0ed8

Browse files
committed
version updates
1 parent a3bb640 commit 80e0ed8

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

Diff for: docs/debugger/create-custom-views-of-native-objects.md

+19-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The same `TextBox` looks much simpler in the variable window when Natvis custom
4040

4141
## <a name="BKMK_Using_Natvis_files"></a>Use .natvis files in C++ projects
4242

43-
Natvis uses *.natvis* files to specify visualization rules. A *.natvis* file is an XML file with a *.natvis* extension. The Natvis schema is defined in *\<VS Installation Folder\>\Xml\Schemas\natvis.xsd*.
43+
Natvis uses *.natvis* files to specify visualization rules. A *.natvis* file is an XML file with a *.natvis* extension. The Natvis schema is defined in *\<VS Installation Folder\>\Xml\Schemas\1033\natvis.xsd*.
4444

4545
The basic structure of a *.natvis* file is one or more `Type` elements representing visualization entries. The fully qualified name of each `Type` element is specified in its `Name` attribute.
4646

@@ -127,18 +127,24 @@ The *.natvis* files are evaluated in the following order:
127127

128128
3. Any *.natvis* files installed and registered via a VSIX package.
129129

130-
::: moniker range="vs-2017"
130+
::: moniker range=">= vs-2022"
131131

132-
4. The user-specific Natvis directory (for example, *%USERPROFILE%\Documents\Visual Studio 2017\Visualizers*).
132+
4. The user-specific Natvis directory (for example, *%USERPROFILE%\Documents\Visual Studio 2022\Visualizers*).
133133

134134
::: moniker-end
135135

136-
::: moniker range=">= vs-2019"
136+
::: moniker range="vs-2019"
137137

138138
4. The user-specific Natvis directory (for example, *%USERPROFILE%\Documents\Visual Studio 2019\Visualizers*).
139139

140140
::: moniker-end
141141

142+
::: moniker range="vs-2017"
143+
144+
4. The user-specific Natvis directory (for example, *%USERPROFILE%\Documents\Visual Studio 2017\Visualizers*).
145+
146+
::: moniker-end
147+
142148
5. The system-wide Natvis directory (*\<VS Installation Folder\>\Common7\Packages\Debugger\Visualizers*). This directory has the *.natvis* files that are installed with Visual Studio. If you have administrator permissions, you can add files to this directory.
143149

144150
## Modify .natvis files while debugging
@@ -154,6 +160,7 @@ If you modify the *.natvis* file outside of Visual Studio, the changes don't tak
154160
Also use the **.natvisreload** command to upgrade the *.natvis* file to a newer version. For example, the *.natvis* file may be checked into source control, and you want to pick up recent changes that somebody else made.
155161

156162
## <a name="BKMK_Expressions_and_formatting"></a> Expressions and formatting
163+
157164
Natvis visualizations use C++ expressions to specify the data items to display. In addition to the enhancements and limitations of C++ expressions in the debugger, which are described in [Context operator (C++)](../debugger/context-operator-cpp.md), be aware of the following:
158165

159166
- Natvis expressions are evaluated in the context of the object being visualized, not the current stack frame. For example, `x` in a Natvis expression refers to the field named **x** in the object being visualized, not to a local variable named **x** in the current function. You can't access local variables in Natvis expressions, although you can access global variables.
@@ -237,6 +244,7 @@ A basic `Type` looks like this example:
237244
3. What the members of the type should look like when the user expands the type in a variable window (the `Expand` node).
238245

239246
#### Templated classes
247+
240248
The `Name` attribute of the `Type` element accepts an asterisk `*` as a wildcard character that can be used for templated class names.
241249

242250
In the following example, the same visualization is used whether the object is a `CAtlArray<int>` or a `CAtlArray<float>`. If there's a specific visualization entry for a `CAtlArray<float>`, then it takes precedence over the generic one.
@@ -250,9 +258,11 @@ In the following example, the same visualization is used whether the object is a
250258
You can reference template parameters in the visualization entry by using macros $T1, $T2, and so forth. To find examples of these macros, see the *.natvis* files shipped with Visual Studio.
251259

252260
#### <a name="BKMK_Visualizer_type_matching"></a> Visualizer type matching
261+
253262
If a visualization entry fails to validate, the next available visualization is used.
254263

255264
#### Inheritable attribute
265+
256266
The optional `Inheritable` attribute specifies whether a visualization applies only to a base type, or to a base type and all derived types. The default value of `Inheritable` is `true`.
257267

258268
In the following example, the visualization applies only to the `BaseClass` type:
@@ -288,6 +298,7 @@ The following example first parses the entry that matches the 2015 STL. If that
288298
```
289299

290300
### Optional attribute
301+
291302
You can put an `Optional` attribute on any node. If a subexpression inside an optional node fails to parse, the debugger ignores that node, but applies the rest of the `Type` rules. In the following type, `[State]` is non-optional, but `[Exception]` is optional. If `MyNamespace::MyClass` has a field named _`M_exceptionHolder`, both the `[State]` node and the `[Exception]` node appear, but if there's no `_M_exceptionHolder` field, only the `[State]` node appears.
292303

293304
```xml
@@ -336,6 +347,7 @@ The `IncludeView` and `ExcludeView` attributes specify elements to display or no
336347
You can use the `IncludeView` and `ExcludeView` attributes on types and on individual members.
337348

338349
### <a name="BKMK_Versioning"></a> Version element
350+
339351
The `Version` element scopes a visualization entry to a specific module and version. The `Version` element helps avoid name collisions, reduces inadvertent mismatches, and allows different visualizations for different type versions.
340352

341353
If a common header file that is used by different modules defines a type, the versioned visualization appears only when the type is in the specified module version.
@@ -437,6 +449,7 @@ The debugger automatically creates the **[Raw View]** node for every custom expa
437449
> If the expression of the item element points to a complex type, the **Item** node itself is expandable.
438450
439451
#### <a name="BKMK_ArrayItems_expansion"></a> ArrayItems expansion
452+
440453
Use the `ArrayItems` node to have the Visual Studio debugger interpret the type as an array and display its individual elements. The visualization for `std::vector` is a good example:
441454

442455
```xml
@@ -633,6 +646,7 @@ The following example shows how to aggregate properties from the base class in a
633646
The **nd** format specifier, which turns off visualization matching for the derived class, is necessary here. Otherwise, the expression `*(CFrameworkElement*)this` would cause the `CPanel` visualization to be applied again, because the default visualization type matching rules consider it the most appropriate one. Use the **nd** format specifier to instruct the debugger to use the base class visualization, or the default expansion if the base class has no visualization.
634647

635648
#### <a name="BKMK_Synthetic_Item_expansion"></a> Synthetic item expansion
649+
636650
While the `ExpandedItem` element provides a flatter view of data by eliminating hierarchies, the `Synthetic` node does the opposite. It allows you to create an artificial child element that isn't a result of an expression. The artificial element can have child elements of its own. In the following example, the visualization for the `Concurrency::array` type uses a `Synthetic` node to show a diagnostic message to the user:
637651

638652
```xml
@@ -699,6 +713,7 @@ Each type defined in the *.natvis* file must explicitly list any UI visualizers
699713
You can see an example of a `UIVisualizer` in the [Image Watch](https://marketplace.visualstudio.com/search?term=%22Image%20Watch%22&target=VS&category=All%20categories&vsVersion=&sortBy=Relevance) extension used to view in-memory bitmaps.
700714

701715
### <a name="BKMK_CustomVisualizer"></a>CustomVisualizer element
716+
702717
`CustomVisualizer` is an extensibility point that specifies a VSIX extension that you write to control visualizations in Visual Studio code. For more information about writing VSIX extensions, see the [Visual Studio SDK](../extensibility/visual-studio-sdk.md).
703718

704719
It's a lot more work to write a custom visualizer than an XML Natvis definition, but you're free from constraints about what Natvis does or doesn't support. Custom visualizers have access to the full set of debugger extensibility APIs, which can query and modify the debuggee process or communicate with other parts of Visual Studio.

0 commit comments

Comments
 (0)