VisualizerObjectSource Class

Definition

Provides access to the object being visualized.
Subclass this class to provide custom functionality.

public ref class VisualizerObjectSource
[Windows::Foundation::Metadata::WebHostHidden]
class VisualizerObjectSource
public class VisualizerObjectSource
type VisualizerObjectSource = class
Public Class VisualizerObjectSource
Inheritance
VisualizerObjectSource

Examples

[assembly: System.Diagnostics.DebuggerVisualizer(  
   typeof(MyFirstVisualizer.DebuggerSide),  
   // The object source is specified on the next line <<<<<  
   typeof(VisualizerObjectSource),  
   Target = typeof(System.String),  
   Description = "My First Visualizer")]  

Remarks

A visualizer is a small program that the Visual Studio debugger uses to display (visualize) an object of a specific data type in meaningful manner. To visualize an object, a visualizer uses code that runs in the debugger process (the debugger side) and code in the process being debugged (the debuggee side).

The debugger side and debuggee side communicate with each other by using VisualizerObjectSource and IVisualizerObjectProvider.

The debugee side uses the DebuggerVisualizerAttribute to specify a VisualizerObjectSource object for the debugger side. The debugger side has access to it indirectly through the IVisualizerObjectProvider interface.

Constructors

VisualizerObjectSource()

Properties

IsBinaryFormatterSupported

Returns true if the debuggee process where the visualizer is hosted supports the Binary Formatter class. If that is not the case, classes that derive from this class should serialize their objects via JSON.

Methods

CreateReplacementObject(Object, Stream)

Creates and returns a replacement object for the object passed in based on the serialized data.

Deserialize(Stream)

Legacy helper method used by old visualizers that makes it easier to write serialization code. It uses default binary serialization to read the given object from the stream. However, due to security vulnerabilities with its usage, it should no longer be used, and will throw on newer versions of .NET like ASP.NET Core 5.0.

If called on a target app that supports Binary Serialization, after the method finishes the stream read pointer is advanced past the bytes of the object

GetData(Object, Stream)

Gets a blob of data. Writes data from the object into the memorystream.

GetDeserializableObject(Stream)

Helper method that can be used to get a deserializable object for cases in which the target app might not support Binary Serialization. In these cases the underlying format should be serialized using JSON, so callers can query individual properties to determine the type of the object they want to deserialize.

Serialize(Stream, Object)

Helper method which makes it easier to write serialization code.

This will use the BinaryFormatter when the target app process supports it, or JSON in cases where it will not. By default, ASP.NET Core 5.0+ disables the binary formatter.

TransferData(Object, Stream, Stream)

Invoked when the UI-side visualizer type calls IVisualizerObjectProvider.TransferData(Stream) or IVisualizerObjectProvider.TransferObject(object).

This method can be used to define a custom message passing protocol to communicate between the UI-side and debuggee-side visualizer types, or to invoke custom actions on the debuggee-side visualizer type. The UI-side visualizer type can pass in arbitrary data serialized into incomingData and the debuggee-side visualizer type can respond with arbitrary data serialized into outgoingData.

Applies to