Categories
.net

Visual Studio.NET 200x Debugger Feature

Last week I’ve presented “What’s new in Visual Studio 2005 Debugger”. One of the cool feature is that you can customize the instance value. For example, consider this simple class:


 public class Tubo
{
   private string Name;
   private string Surname;
   …
}


In debugger you would see something like:


Variable | Value      | Type
————————————–
tubo | namespace.Tubo | namespace.Tubo


One way of changing the Value display (the other way is applying DisplayValueAttribute either to class or assembly) is to override ToString() method:


public override string ToString()
{
   return Name + “, ” + Surname;


}


This time you’ll see something like this:


Variable | Value      | Type
————————————-
tubo | “Tom, Arraya” | namespace.Tubo


This way the display is quite a bit more informative than before.


Interesting fact is, that Visual Studio.NET 2003 already has this feature. It wasn’t as easy as overriding ToString() or applying an attribute though. So, how could one customize it in actual Visual Studio.NET?


There are three files located in C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Packages\Debugger folder:



  • mcee_cs.dat
  • mcee_mc.dat
  • vjsee.dat

I am not sure why they are three similar files. Perhaps each of them is linked to certain language (C#, MC++, J#). Anyway, I experimented with mcee_cs.dat since I mainly program with C#. If we go back to Tubo example, I would add this line to mcee_cs.dat file:


=,


and Visual Studio.NET 2003 will display the same value as in our 2005 beta 2 example. I guess the example is simple enough to understand the above line structure. Its get even better. There is a VSTweak PowerToy project going on at GotDotNet web site. I’ve donated an editor for mcee_cs.dat file to the project. It features Intellisense like technology and few automation tricks that helps you create all those nice lines that will help you out inspecting variables.


So, if you want to enhance Visual Studio.NET 2002/2003 debugger display don’t hesitate. The feature is there.

One reply on “Visual Studio.NET 200x Debugger Feature”

Leave a Reply