none
How to display a derived class information in natvis?

    Question

  • Hello guys,

    I have a very shallow but wide hierarchy of simple classes.

    Let's say I have a base class A, and then classes B, C, D, E, ... all of which derive from A.

    Is there a way to write a visualization of class A and add the static data of any derived class?

    What I mean is instead of doing the following:

    <Type Name="A">
        <DisplayString>A</DisplayString>
        <Expand>
            <Item Name="a1">m_a1</Item>
            <Item Name="a2">m_a2</Item>
        </Expand>
    </Type>
    
    <Type Name="B">
        <DisplayString>B</DisplayString>
        <Expand>
            <ExpandedItem>(A*)this,nd</ExpandedItem>
            <Item Name="b">m_b</Item>
        </Expand>
    </Type>
    
    <Type Name="C">
        <DisplayString>C</DisplayString>
        <Expand>
            <ExpandedItem>(A*)this,nd</ExpandedItem>
            <Item Name="c">m_c</Item>
        </Expand>
    </Type>

    To be able to do this:

    <Type Name="A">
        <DisplayString>A</DisplayString>
        <Expand>
            <Item Name="a1">m_a1</Item>
            <Item Name="a2">m_a2</Item>
            <ExpandedItem>(AnyDerived*)this,nd</ExpandedItem>
        </Expand>
    </Type>

    Regards,

    Rado


    Wednesday, November 28, 2018 12:57 PM

Answers

  • Hi Rado,

    It is not possible. There’s no symbol for the derived type in the natvis.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 7, 2018 7:18 AM
    Moderator