4

I am trying to make use of the tag which is defined in natvis.xsd (The natvis schema file) in order to write C# or C++ code to visualize a type. I cannot find any documentation on this, so I'm not sure how it works. In particular I need to specify a GUID for the CustomVisualizer. What does this GUID map to? How do I export the class that is registered with this GUID? What interface do I need to implement? In short, how do I connect the GUID that I specify in the .natvis file to the code that formats the object?

The documentation for natvis does not mention the existence of the CustomVisualizer tag, but it's in the natvis schema file and shows up in autocomplete. I found that PyTools appears to implement natvis Custom Visualizers using this method, but it seems some of the code is hidden, and I'm unable to locate the source for the actual native visualizer using this method.

Here is an example natvis file I would like to make work:

<?xml version="1.0" encoding="utf-8" ?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
  <Type Name="MyCustomVisualizer">
    <CustomVisualizer VisualizerId="{387446F9-4B29-4EE7-A948-346BF6995603}"/>
  </Type>
</AutoVisualizer>

And I'm asking specifically about how to write the C# and/or C++ code to make this work.

KindDragon
  • 6,558
  • 4
  • 47
  • 75
Zachary Turner
  • 738
  • 4
  • 24

3 Answers3

2

https://code.msdn.microsoft.com/Writing-graphical-debugger-a17e3d75

You want to use a UIVisualizer, instead of a CustomVisualizer. Although CustomVisualizer appears in the schema, there appears to be no documentation about it. With the UIVisualizer, you get the inspector window in the watch view, which will launch the visualizer. The usage of the GUIDs related to the UIVisualizer are also discussed in that link.

MuertoExcobito
  • 9,741
  • 2
  • 37
  • 78
2

Figured this out. You can see source at https://github.com/chromium/vs-chromium

TL;DR - There's a ton of work involved, I probably did some things wrong, and it's not easy.

Zachary Turner
  • 738
  • 4
  • 24
0

I don't how use CustomVisualizer, but maybe visualizer that use LegacyAddin can solve your problem https://stackoverflow.com/a/11545420/61505

Community
  • 1
  • 1
KindDragon
  • 6,558
  • 4
  • 47
  • 75