How to propagate the view type in natvis from standard containers to their items?

547 views Asked by At

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

0

There are 0 answers