c# – A separate Debugger Visualizer window for each variable of the same type


I want to create my custom Debugger Visualizer for my type.
I am using Visual Studio 2022 and i create “VisualStudio.Extensibiliy Extention with VSSDK Compatibility” type project. I also create MyVisualizer.cs file and inherits from DebuggerVisualizerProvider class. Then i add to project my WPF MainUserControl.cs ( inherits from class UserControl) and MainUserControl.xaml. Then in function CreateVisualizerAsync of the MyVisualizer.cs file i write this:

await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
MainUserControl muc = new MainUserControl();
var wrap = new WpfControlWrapper(muc);
return await Task.FromResult<IRemoteUserControl>(wrap);

I also register my type like this:

public override DebuggerVisualizerProviderConfiguration 
DebuggerVisualizerProviderConfiguration => new(
new VisualizerTargetType("My Visualizer ", typeof(string)))
 {
     Style = VisualizerStyle.ToolWindow
 };

And it works fine, but when i click on two variables of the same type (string in my case) i get only one ToolWindow. And i want Visual Studio to open me two separate ToolWindow for each variable of my type (string). How can i get this?

Leave a Reply

Your email address will not be published. Required fields are marked *