2

It is possible to define different views for types specified in natvis files, however i don't know a way to propagate these views through standard containers without modifying or rewriting the containers natvis.

I have the following test C++ - code:

#include <vector>
struct S {
    double d = 0.123457890;
};
int main() {
    std::vector<S> s(1);
}

and the following visualizer for the type S:

<?xml version="1.0" encoding="utf-8"?> 
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
  <Type Name="S">
    <DisplayString IncludeView="g">{d,g}</DisplayString>
    <DisplayString>{d}</DisplayString>
  </Type>
</AutoVisualizer>

and am looking for a way to select the g view in the watch window of visual studio for containers so that all items of the container s are displayed with the view g.

Here's what i tried but the g view is only applied to the type S when the items are entered directly in the watch window. For long arrays this approach is not feasible:

enter image description here

Dylan
  • 504
  • 2
  • 5
  • 9
jesses
  • 559
  • 3
  • 15
  • I don't think this is possible as easy as you want it. But if you don't care fiddling with the STL.natvis (C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Packages\Debugger\Visualizers\stl.natvis) you can try passing the view for the container down to the container elements using IncludeView/ExcludeView. – Werner Henze May 18 '21 at 19:27

0 Answers0