简体   繁体   中英

Using <CustomVisualizer> tag with natvis

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.

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.

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.

我不是如何使用CustomVisualizer ,但可能使用LegacyAddin可视化LegacyAddin可以解决您的问题https://stackoverflow.com/a/11545420/61505

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM