Click here to Skip to main content
15,886,362 members
Articles / Programming Languages / C#

Visual Studio Collection Visualizers

Rate me:
Please Sign up or sign in to vote.
4.84/5 (24 votes)
11 Apr 2017CPOL2 min read 37.8K   1.1K   36   26
Collection Visualizer for Visual Studio 2015 and Visual Studio 2017. Preview your collections in debug mode.

Introduction

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

I decided to build an assembly support for visualizing and filtering the collection results in debug mode. Sometime later, I updated this assembly to a Visual Studio Visualizer, and today I share it with you, because I think it is a very useful complement.

MLCollectionVisualizers is an open source project and the code is available in Github.

Installation

Installing 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 this path:

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

Image 1

Visual Studio 2017

We must copy the MLCollectionVisualizer2017.dll in this path:

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

Image 2

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 like in our example:

C#
#if DEBUG
[Serializable]
#endif
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; }
}

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

Image 3

Image 4

Image 5

Image 6

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

Filtering

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

We will go the second tab ‘Filters’:

Image 7

Filter InfoLinkedLabel - Contains a link with filtered information, all instructions and restrictions.

Apply Filter Button - Executed the filter

Example:

Image 8

Image 9

In moving:

Image 10

Image 11

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

Image 12

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

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 special characteristics:

Image 13

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

C#
context.Configuration.ProxyCreationEnabled = false;

Image 14

Test Project

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

History

  • 11th April, 2011: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Cecabank
Spain Spain
MVP C# Corner 2017

MAP Microsoft Active Professional 2014

MCPD - Designing and Developing Windows Applications .NET Framework 4
MCTS - Windows Applications Development .NET Framework 4
MCTS - Accessing Data Development .NET Framework 4
MCTS - WCF Development .NET Framework 4

Comments and Discussions

 
GeneralRe: Unable to load the custom visualizer Pin
Darren Schroeder11-Apr-17 5:36
Darren Schroeder11-Apr-17 5:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.