Click here to Skip to main content
15,879,326 members
Articles / Programming Languages / C#

A Generic List and Dictionary Debugger Visualizer for VS.NET

Rate me:
Please Sign up or sign in to vote.
4.91/5 (36 votes)
27 Aug 2011CPOL2 min read 159.9K   3.8K   103  
A cool List and Dictionary debugger visualizer for VS.NET 2005, 2008 and 2010
using System.Collections;
using System.Windows.Forms;
using System.Collections.Generic;
using Microsoft.VisualStudio.DebuggerVisualizers;
using VisualizerLib;

[assembly: System.Diagnostics.DebuggerVisualizer(
typeof(ListVisualizer.DebuggerSide),
typeof(VisualizerObjectSource),
Target = typeof(List<>),
Description = "List Visualizer")]
namespace ListVisualizer
{
    public class DebuggerSide : DialogDebuggerVisualizer
    {
        #region Visualizer Logic

        private ListProcessor listProcessor;

        override protected void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
        {
            // Initialize datagrid and form
            InitializeComponent();

            try
            {
                // Get the list in the grid view
                IList list = (IList)objectProvider.GetObject();
                listProcessor = new ListProcessor(list);
                listProcessor.GetList(dgvList);
            }
            catch { }

            // Show the grid with the list
            windowService.ShowDialog(form);
        }

        #endregion

        #region Windows Form Designer generated code

        private System.Windows.Forms.DataGridView dgvList;
        private System.Windows.Forms.Form form;

        private void InitializeComponent()
        {
            this.dgvList = new System.Windows.Forms.DataGridView();
            ((System.ComponentModel.ISupportInitialize)(this.dgvList)).BeginInit();
            form = new Form();
            form.SuspendLayout();
            // 
            // dgvList
            // 
            this.dgvList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.dgvList.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dgvList.Location = new System.Drawing.Point(16, 15);
            this.dgvList.Margin = new System.Windows.Forms.Padding(4);
            this.dgvList.Name = "dgvList";
            this.dgvList.ReadOnly = true;
            this.dgvList.RowTemplate.Height = 24;
            this.dgvList.Size = new System.Drawing.Size(646, 486);
            this.dgvList.TabIndex = 0;
            // 
            // ListVisualizer
            // 
            form.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
            form.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            form.ClientSize = new System.Drawing.Size(675, 514);
            form.Controls.Add(this.dgvList);
            form.Margin = new System.Windows.Forms.Padding(4);
            form.Name = "ListVisualizer";
            form.Text = "List Visualizer";
            ((System.ComponentModel.ISupportInitialize)(this.dgvList)).EndInit();
            form.ResumeLayout(false);
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Architect
Brazil Brazil
I started development 37 years from now, since MSX basic. Started Windows programming with VB 2.0 and Web programming with ASP 3.0. Then I built Windows Forms, Web Applications, NT services and WPF applications using Microsoft.NET. I am MCP in Visual Basic 6.0, MCAD and MCSD.NET in Framework 1.1, MCPD Web in Framework 2.0, MCTS in .NET 3.5 workflow, MCTS in .NET 3.5 communication foundation, windows presentation foundation and MVC applications. Built MVC Web Application and WCF services using Micro Services architecture proposed by me. Working with AI projects to improve the business performance and customer experience. Besides programming I love running, swimming, reading and movies.

Comments and Discussions