I am using the latest version of VS2022.
I was trying to use the 'new' Extension implementation and followed the following docs:
https://blog.elmah.io/creating-custom-debug-visualizers-for-visual-studio-2022/
targeting net8.0.
so the interesting parts are quite short:
/// <summary>
/// Debugger visualizer provider class for <see cref="System.String"/>.
/// </summary>
[VisualStudioContribution]
internal class CTypesDebuggerVisualizerProvider : DebuggerVisualizerProvider
{
/// <summary>
/// Initializes a new instance of the <see cref="CTypesDebuggerVisualizerProvider"/> class.
/// </summary>
/// <param name="extension">Extension instance.</param>
/// <param name="extensibility">Extensibility object.</param>
public CTypesDebuggerVisualizerProvider(
CTypesVisualizer.CTypesDebuggerVisualizerExtension extension,
VisualStudioExtensibility extensibility)
: base(extension, extensibility)
{
}
/// <inheritdoc/>
public override DebuggerVisualizerProviderConfiguration DebuggerVisualizerProviderConfiguration
=> new
(
//new VisualizerTargetType("Byte* Visualizer", typeof(byte*).AssemblyQualifiedName!),
//new VisualizerTargetType("Byte* Visualizer", typeof(byte*)),
new VisualizerTargetType("CTypes Visualizer", typeof(Byte[]))
)
{
VisualizerObjectSourceType = new(typeof(CTypesVisualizerSource.CTypesObjectSource)),
};
/// <inheritdoc/>
public override async Task<IRemoteUserControl> CreateVisualizerAsync(
VisualizerTarget visualizerTarget, CancellationToken cancellationToken)
{
VisualizerObjectSourceClient client = visualizerTarget.ObjectSource;
CTypesModel? model = await visualizerTarget
.ObjectSource
.RequestDataAsync<CTypesModel>(jsonSerializer: null, CancellationToken.None);
return await Task.FromResult<IRemoteUserControl>(
new CTypesVisualizer.CTypesVisualizerUserControl(model));
}
}
and on the other side
public class CTypesObjectSource : VisualizerObjectSource
{
public CTypesObjectSource()
{
}
public override void GetData(object target, Stream outgoingData)
{
var result = new CTypesModel
{
Name = "Test byte[]",
Length = 0,
DataString = "Test Mode Data"
};
SerializeAsJson(outgoingData, result);
}
}
the Byte[] type seems to also apply for the byte* variable ....
but if i click the view, i get the error message
if i do the same on a 'real' byte[] variable, everything works fine.
The exception occurs before the GetData method on the debugee-side is called.