3

So, say I have 2 classes, C and B where they have a composition relationship, C is composed of B.

struct C
{
};

struct B
{
  C c;
};

Now, I have a natvis file that has 2 views of C. Must I explicitly propagate this view from B to C? This sounds like a lot of hassle since the natvis file doesn't state the types that are being displayed resulting in missing locations where I want that view propagated. Also, this wouldn't work for containers. I would only have a view for an individual item.

EDIT:

Example:

<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
  <Type Name="C">
    <DisplayString>View 1</DisplayString>
  </Type>

  <Type Name="C" IncludeView="two">
    <DisplayString>View 2</DisplayString>
  </Type>

  <Type Name="B">
    <DisplayString>B</DisplayString>
    <Expand>
      <Item Name="C">c</Item>
    </Expand>
  </Type>
</AutoVisualizer>

Now in the watch window I look at a variable b which is of type B. To see it, I type:

b, view(two)

To which I would expect the view to propagate to the view of c. But it doesn't. It would instead show:

c    View 1

Without having to write:

  <Type Name="B">
    <DisplayString>B</DisplayString>
    <Expand>
      <Item Name="C" ExcludeView="two">c</Item>
      <Item Name="C" IncludeView="two">c</Item>
    </Expand>
  </Type>

How would I accomplish this?

Werner Henze
  • 16,404
  • 12
  • 44
  • 69
Adrian
  • 10,246
  • 4
  • 44
  • 110

1 Answers1

0

Unfortunately, you can't pass the view type to nested elements. Even for your example

  <Type Name="B">
    <DisplayString>B</DisplayString>
    <Expand>
      <Item Name="C1" ExcludeView="two">c</Item>
      <Item Name="C2" IncludeView="two">c</Item>
    </Expand>
  </Type>

it doesn't work as expected:

example

You have to add , view(two) to get right view:

  <Type Name="B">
    <DisplayString>B</DisplayString>
    <Expand>
      <Item Name="C1" ExcludeView="two">c</Item>
      <Item Name="C2" IncludeView="two">c, view(two)</Item>
    </Expand>
  </Type>

tested on MSVS 2019

mr NAE
  • 3,144
  • 1
  • 15
  • 35