I am writing debugger visualizers using a .natvis file in Microsoft Visual Studio 2015. There is one piece of information in my class that I would like to get at if possible. I'm wondering what the syntax would be to get at that variable.
Here is a simplified version of the C++ code:
class MyClass
{
public:
MyClass() {}
int getAValue(size_t index)
{
static std::vector<int> numberVector;
if (numberVector.size() <= index)
{
addSomeNumbersToTheEnd(numberVector);
}
return numberVector[i];
}
}
In the debugger, I would like to see the size of the vector when I hover over an instance of MyClass, but I don't know how to reference it (or if that is even possible). Here is the visualizer Type, with <what goes here?>
at the place where I'm having trouble:
<Type Name="MyClass">
<DisplayString>[$(Type)] staticVectorSize={<what goes here?>}</DisplayString>
</Type>
The actual problem is much more complicated, involving the curiously recurring template pattern to create better enumeration objects, so please no comments about the uselessness of this somewhat contrived scenario.