Microsoft.VisualStudio.DebuggerVisualizers Namespace

 

IVisualizerObjectProvider.GetData Method ()

Stream GetData()

Return Value

Type: System.IO.Stream

A stream of data containing the contents of the object being visualized. Calling this method results in VisualizerObjectSource.GetData being called on the VisualizerObjectSource. The return value of that GetData call is then returned to the caller of this method.

GetObject calls this method and deserializes the stream into an object.

public class DebuggerSide : DialogDebuggerVisualizer
{
   override protected void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
   {
      Stream myStream = objectProvider.GetData();
      Stream myNewStream;
      // Here is where you would deserialize the data into a useful 
      // format and show the visualizer
      // Make sure the object is replacable before you try to replace 
      // it. Otherwise, you will get an exception.
      if (objectProvider.IsObjectReplaceable)
        {
         // reserialize here
         objectProvider.ReplaceData(myNewStream); 
        }
   }
   // Other class methods would be here.
}
Return to top

IVisualizerObjectProvider.GetObject Method ()

object GetObject()

Return Value

Type: System.Object

The data object being visualized. This is actually a debugger-side copy of the object you are visualizing in the debuggee. If you modify the contents of this object, the changes will not be reflected back in the debuggee unless you use the ReplaceData/ReplaceObject or TransferData/TransferObject.

Calls GetData and deserializes the data into an object.

public class DebuggerSide : DialogDebuggerVisualizer
{
   override protected void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
   {
      MessageBox.Show(objectProvider.GetObject().ToString());

// Other DebuggerSide methods ommitted for clarity.
}
Return to top

IVisualizerObjectProvider.ReplaceData Method (Stream)

void ReplaceData(
	Stream newObjectData
)

Parameters

newObjectData
Type: System.IO.Stream

A stream containing data to be used to create a new object, replacing the object currently being visualized.

Replaces the contents of the object being visualized with the contents of the data stream you specify. Sends the contents of the stream parameter to the ObjectSource class, for that class to do anything it needs with it.

Calling this method results in a call to CreateReplacementObject on the VisualizerObjectSource. The return value of the call will become the new object being visualized.

public class DebuggerSide : DialogDebuggerVisualizer
{
   override protected void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
   {
      Stream myStream = objectProvider.GetData();
      Stream myNewStream;
      // Here is where you would show the visualizer and deserialize
      // Make sure the object is replacable before you try to replace 
      // it. Otherwise, you will get an exception.
      if (objectProvider.IsObjectReplaceable)
      {
       // Reserialize here
       objectProvider.ReplaceData(myNewStream); 
      }
   }
   // Other class methods would be here.
}
Return to top

IVisualizerObjectProvider.ReplaceObject Method (Object)

void ReplaceObject(
	object newObject
)

Parameters

newObject
Type: System.Object

The new object to replace the object currently being visualized.

Replaces the object being visualized with a new object that you specify. This results in the newObject parameter being serialized and passed to the ReplaceData method.

public class DebuggerSide : DialogDebuggerVisualizer
{
   override protected void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
   {
      // Get a string from the debuggee side and display it in a message box.
      String myString = objectProvider.GetObject().ToString();
      MessageBox.Show(myString);

      // Modify the string and send it back to the debuggee side.
      String myNewString = myString.ToUpper();
      // Make sure the object is replacable before you try to replace it.
      // Otherwise, you will get an exception.
      if (objectProvider.IsObjectReplaceable)
      {
      // This example assumes the object source is expecting a string.
         objectProvider.ReplaceObject(myNewString);
      }
   }
// Other DebuggerSide methods ommitted for clarity.
}
Return to top

IVisualizerObjectProvider.TransferData Method (Stream)

Stream TransferData(
	Stream outgoingData
)

Parameters

outgoingData
Type: System.IO.Stream

A stream of data that is to be transferred back to the debuggee side.

Return Value

Type: System.IO.Stream

Returns the data stream filled in by VisualizerObjectSource's TransferData method. There is no two-way stream-based communication between the debugger side and debuggee side (object source.)

Transfers arbitrary data to the VisualizerObjectSource and allows it to return any arbitrary data.

public class DebuggerSide : DialogDebuggerVisualizer
{
   override protected void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
   {
      Stream myStream = objectProvider.GetData();
      Stream myNewStream;
      // Here is where you would show the visualizer and get back the modified data stream
      objectProvider.TransferData(myNewStream);
   }
   // Other class methods would be here.
}
Return to top

IVisualizerObjectProvider.TransferObject Method (Object)

object TransferObject(
	object outgoingObject
)

Parameters

outgoingObject
Type: System.Object

An object that is to be transferred back to the debuggee side.

Return Value

Type: System.Object

The result of deserializing the return value of TransferData.

Transfers a data object back to the debuggee. Call this method after replacing the object that is being visualized. Call this method to transfer some information or call a command on the VisualizerObjectSource. This method merely wraps TransferData with calls to serialization and deserialization helper methods.

public class DebuggerSide : DialogDebuggerVisualizer
{
   override protected void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
   {
      // Get a string from the debuggee side and display it in a message box.
      String myString = objectProvider.GetObject().ToString();
      MessageBox.Show(myString);

      // Modify the string and send it back to the debuggee side.
      String myNewString = myString.ToUpper();
      objectProvider.TransferObject(myNewString);
   }
// Other DebuggerSide methods ommitted for clarity.
}
Return to top

IVisualizerObjectProvider.IsObjectReplaceable Property

bool IsObjectReplaceable { get; }

Property Value

Type: System.Boolean

Determines whether the data object being visualized is replaceable (read/write) or nonreplaceable (read only).

Before you attempt to replace data by calling ReplaceData or ReplaceObject, call this method to determine whether the object is replaceable. If this method returns a value of false, treat the object as read-only.

public class DebuggerSide : DialogDebuggerVisualizer
{
   override protected void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
   {
      // Get a string from the debuggee side and display it in a message box.
      String myString = objectProvider.GetObject().ToString();
      MessageBox.Show(myString);

      // Modify the string and send it back to the debuggee side.
      String myNewString = myString.ToUpper();
      // Make sure the object is replacable before you try to replace it.
      // Otherwise, you will get an exception.
      if (objectProvider.IsObjectReplaceable)
      {
         objectProvider.ReplaceObject(myNewString);
      }
   }
// Other DebuggerSide methods ommitted for clarity.
}
Return to top

IVisualizerObjectProvider Interface

public interface IVisualizerObjectProvider

A visualizer is a small program the Visual Studio debugger uses to display, that is, visualize, an object of a specific data type in meaningful fashion. 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 using VisualizerObjectSource and IVisualizerObjectProvider.

The debuggee side uses VisualizerObjectSource to specify a VisualizerObjectSource object for the debugger side. The debugger side requests and receives this information by calling methods on the IVisualizerObjectProvider interface.

A visualizer can edit, as well as display, data. If your visualizer supports editing data, you must replace the data entirely by calling ReplaceData or ReplaceObject or transfer data back to the debuggee using TransferData or TransferObject. If you want to save data back, you also need to create your own object source.

public class DebuggerSide : DialogDebuggerVisualizer
{
   override protected void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
   {
      MessageBox.Show(objectProvider.GetObject().ToString());
   }
// . . . Other methods omitted for clarity.
}
Return to top
Show: