Search code examples
visual-studiodebuggingvisual-studio-2015natvis

VS2015 Visualiser, (*.natvis) DisplayString call a function to display the value


I have a complex class, (MyClass), that has a function called ToString(), the function returns a string representation of the string.

I would like the visual studio visualiser to use that function to display the variable

This is my visualizer,

<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
  <Type Name="MyClass">
    <DisplayString>...</DisplayString> 
  </Type>
</AutoVisualizer>

If I use

...
  <DisplayString>{ToString}</DisplayString> 
...

The address of the function is returned, is it possible to display the result of the function?

If not, what would be the best way of displaying a string representation of the class?


Solution

  • Methods cannot be called.

    From MSDN Forums:

    Calling a function from the debugger is playing with fire. You are likely to deadlock on cross thread dependencies (even if you don't have any explicit cross thread dependencies, there are shared locks for things like memory allocation). This is why the C++ debugger has no support for implicit funceval