TWC9: Visual Studio 2012 5.5 million downloads, VS2013 Virtual Launch, ScriptCS and more...

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...
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
, andDataView
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 useDataRowVisualizerObjectSource
, this is because theDataRow
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:...
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:
...
And as you expect the source for all this is available too...
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.
I once did this for Image, also useful.
This conversation has been locked by the site admins. No new comments can be made.