Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Visual Studio Data (Set, Table, Row, View, RowView, RowViewCollection) Visualizer

Today's "I don't know what to call it" Wednesday project is one that's just a little different, not a game or anything, but something I've not seen mentioned too much recently.

Visual Studio has these cool things to help you in your debugging, called Visualizers. They help you see beyond the code and into the data, using a custom dialog or interface. And while there's a number in the box, they can't build one for everything.

But Visual Studio being what it is, you can create your own...

Visual Studio Visualizer: Part 1

Add a Visual Studio Visualizer to look data from: 

  • Dataset; 
  • DataTable; 
  • DataRow; 
  • DataView; 
  • DataRowView; 
  • DataRowCollection.

Using the code

Visit the project home page, download your flavor (2010 or 2012), unzip, and place the DLLs in the right folder, Documents\Visual Studio xxxx\Visualizers

When debugging with VS there is a extra option for visualizer, for the DataSet, DataTable, DataRow, and DataView objects. 

Points of Interest

For some reason arrays are not allowed for visualizing within visual studio debug, but when using the VisualizerDevelopmentHost class to test the visualizer, an array is allowed.

This project shows a work around to make a non-serializable object available to our custom visualizer. 

Create a visualizer

This project was created using visual studio express, any edition can be used.

First create a class library project then add a reference to the Visual Studio Visualizer API, the DLL can be found on: (Visual Studio installation folder)\Common7\IDE\ReferenceAssemblies\v2.0 Microsoft.VisualStudio.DebuggerVisualizers.dll

Add references to the types of objects, the visualizer will receive:

[assembly: System.Diagnostics.DebuggerVisualizer(
    typeof(DSVisualizer), typeof(VisualizerObjectSource), Target = typeof(DataSet), Description = "My DataSet Visualizer")]
[assembly: System.Diagnostics.DebuggerVisualizer(
    typeof(DTVisualizer), typeof(VisualizerObjectSource), Target = typeof(DataTable), 
    Description = "My DataTable Visualizer")]
[assembly: System.Diagnostics.DebuggerVisualizer(
    typeof(DRVisualizer), typeof(DataRowVisualizerObjectSource), 
    Target = typeof(DataRow), Description = "My DataRow Visualizer")]
[assembly: System.Diagnostics.DebuggerVisualizer(
    typeof(DVVisualizer), typeof(DataRowVisualizerObjectSource), 
    Target = typeof(DataView), Description = "My DataView Visualizer")]
[assembly: System.Diagnostics.DebuggerVisualizer(
    typeof(DRVVisualizer), typeof(DataRowVisualizerObjectSource), 
    Target = typeof(DataRowView), Description = "My DataRowView Visualizer")]
[assembly: System.Diagnostics.DebuggerVisualizer(
    typeof(DRCollectionVisualizer), typeof(DataRowVisualizerObjectSource), 
    Target = typeof(DataRowCollection), Description = "My DataRowCollection Visualizer")]

This can be inside any cs file of the project, but it must be outside any namespace declaration. As you can see, some types use VisualizerObjectSource and others use DataRowVisualizerObjectSource, this is because the DataRow type needs some massage before we can use it, this is covered later.  

The class that will get the object to visualize must inherits from DialogDebuggerVisualizer

This will allow to override the Show method: 

...

Visual Studio Watchers

This project contains some visualizers to work with Visual Studio.

Currently this project has visualizers for:

  • DataSet
  • DataTable
  • DataRow
  • DataView
  • DataRowView
  • DataRowCollection

There next visualizers will be for entity framework objects (trying to do a visualizer for all custom objects), StringBuilder, string and XDocument.

Introduction

Place the dll's in the right folder, Documents\Visual Studio xxxx\Visualizers.
When debugging with VS there is a extra option for visualizer, for the DataSet, DataTable, DataRow and DataView objects.

DataSet

The dataset visualizer mainpage, show a tree and a datagrid. In the tree all of the datatables are available:

image

...

image

And as you expect the source for all this is available too...

Tags:

Follow the Discussion

  • Paul ApostolosPaul Apostolos

    I was literally just going to start writing one of these. I'd like to have a visualizer for generic collections. If you'd like help with the project, I'm in.

  • Ricardo PeresRicardo Peres

    I once did this for Image, also useful.

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.