lunes, 10 de abril de 2017

Visual Studio Collection Visualizers

The last time, a few years ago, I had to develop a .NET solution with a large set off sequences comparisons between them. This sequences was a big sequences and occasionally it was a living hell to check this results.

I decided built an assembly supports for visualize and filter the collection result in debug mode. Sometime afterwards, I updated this assembly to a Visual Studio Visualizer, and today I shared it with you, because I think is a very useful complement.

MLCollectionVisualizers is an open source project and your code is available in Git Hub.


Install MLCollectionVisualizers is very simple. We need to distinguish between Visual Studio 2015 and Visual Studio 2017.


We must copy the MLCollectionVisualizer2015.dll in this path: 

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Packages\Debugger\Visualizers\


We must copy the MLCollectionVisualizer2017.dll in this path: 

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Packages\Debugger\Visualizers\

Once an assembly has been put in Visual Studio Visualizer path, reboot Visual Studio and our Collection Visualizer will be installed.


MLCollectionVisualizers is very simple to use. We have to mark our class type with SERIALIZABLE. If someone report any discomfort, we can use the preprocessor directives like in our example:

public class Album
    public int      ID             { get; set; }
    public string   Artist         { get; set; }
    public string   AlbumName      { get; set; }
    public int      Released       { get; set; }
    public string   Genre          { get; set; }
    public decimal  NumberOfCopies { get; set; }
    public int      ClaimedSales   { get; set; }


Use it is very easy. We put a breackpoint in a collection variable and we do click in the lens:

As we can see, we can ordered data clicking in ColumHeader of grid.

Collections Supported

MLCollectionVisualizer provide filtering data, this filtered is restricted to the DataColumn.Expression property. Similar to SQL.

We will go the second tab ‘Filters’:

‘Filter Info’ LinkedLabel .- Contains a link with filtered information, all instructions and restrictions.

Apply Filter Button .- Executed the filter


In moving:

If you type an incorrect syntax filter, it will show the error:

In this example the error is ‘=’ symbol.

Collections Supported

The collections supported for MLCollectionsVisualizers are the following:
  • ·         IEnumerable<T>
  • ·         ICollection<T>
  • ·         IList<T>
  • ·         HashSet<T>
  • ·         ObservableCollection<T>
  • ·         Queue<T>
  • ·         Stack<T>
  • ·         LinkedList<T>
  • ·         IReadOnlyCollection<T>
  • ·         ConcurrentBag<T>
  • ·         ConcurrentQueue<T>
  • ·         ConcurrentStack<T>
  • ·         Array ( T[] )
  • ·         IEnumerable
  • ·         ArrayList
  • ·         HashSet
  • ·         Queue
  • ·         Stack


Not supported x64 Process.

Not supported System.Data.Entities.DynamicProxies of Entity Framework. Entity Framework when we query the database, generic for default this objects with a special characteristics:

We can fix up this problem, setup our Entity Framework configuration DbContext to ProxyCreationEnabled to false:

context.Configuration.ProxyCreationEnabled = false;

Test Project

Add a test project for this solution and the MLCollectionVisualizers2015.dll and MLCollectionVisualizers2017.dll 


Projecto de Tests