Visual Studio Collection Visualizers

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

I decided to build an assembly support for visualizing and filtering the collection result sin debug mode. Sometime afterwards, I updated this assembly to a Visual Studio Visualizer, and today I share 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.

Installation

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

Visual Studio 2015

We must copy the MLCollectionVisualizer2015.dll in the path 

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

Visual Studio
Visual Studio 2017

We must copy MLCollectionVisualizer2017.dll in the path

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

Visual Studio

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

MLCollectionVisualizers

MLCollectionVisualizers is very simple to use. We have to mark our class type with SERIALIZABLE. If someone reports any discomfort, we can use the preprocessor Directives, as we did in our example. 

  1. #if DEBUG  
  2. [Serializable]   
  3. #endif  
  4. public class Album  
  5. {  
  6.     public int      ID             { get; set; }  
  7.     public string   Artist         { get; set; }  
  8.     public string   AlbumName      { get; set; }  
  9.     public int      Released       { get; set; }  
  10.     public string   Genre          { get; set; }  
  11.     public decimal  NumberOfCopies { get; set; }  
  12.     public int      ClaimedSales   { get; set; }  
  13.   
  14.   
  15.  

Use it as it is very easy. We put a breakpoint in a collection variable and we need to click in the lens.

Visual Studio

Visual Studio

In moving


 
 

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

Filtering

MLCollectionVisualizer provides filtering data, this filter is restricted to the DataColumn.Expression property. Similar to SQL.

We will go to second tab ‘Filters’.

Visual Studio

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

Apply Filter Button .- Executed the filter

Example

Visual Studio

Visual Studio

In Moving

 

If you type an incorrect syntax filter, it will show the error, as shown below.

Visual Studio

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

Limitations

It does not support x64 process.

It does not support System.Data.Entities.DynamicProxies of an Entity Framework. 

Visual Studio

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

context.Configuration.ProxyCreationEnabled = false

Visual Studio

Test Project

Add a Test Project, MLCollectionVisualizers2015.dll and MLCollectionVisualizers2017.dll for this solution.

Up Next
    Ebook Download
    View all
    Learn
    View all