Archive for the ‘VisualStudio’ Category

VisualStudio TechnologyExplorer : Generate a graph of your solutions(.sln) & projects (.csproj)

Download: You can download the TechnologyExplorer here.
TechnologyExplorer Example
I’m developing with .NET since version 1.1 which was Visual Studio 2003 released in 2003. Since, 5 .NET framework have been released (2, 3, 3.5, 4, 4.5) with 4 VisualStudio (2005, 2008, 2010, 2012).

I have a lot of applications (web, console, windows service and WindowsForm) that used different libraries. I wanted to know the .NET version of every library/application, the VisualStudio version of every applcation and to see the dependencies between the libraries and the applications.

To see the dependencies, you can use the ArchitectureExplorer available in VisualStudio Ultimate. But you can’t extract the .NET version and the VisualStudio version with this tool.
I wanted to use the Graph layout capabilities of VisualStudio so I don’t have to program a algo to place the nodes and reduce the overlap between the links.


To display graphs, VisualStudio use DGML that is a xml file. So you can create manually or by a program a dgml that you can open in VisualStudio.
The specs are available at

Determine the VisualStudio version

The VisualStudio version is available in the sln file:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012


Determine the .NET Framework version

The .net framework version, is available in the csproj under the node TargetFrameworkVersion.


I wrote a application, the TechnologyExplorer, given a base folder, navigate in thew folder and it’s subfolders to extract the .NET version and the VisualStudio version of the applications and libraries.
It generate a dependency graph that shown the applications and the libraries and their dependencies.

  • The background color indicate the type: web application, application or library
  • The outline indicate the .NET framework version
  • For applications, the text color indicate the VisualStudio version

The output is a DGML file that you can open in VisualStudio to see the graph.

TechnologyExplorer Example

The TechnologyExplorer also generate a Legend file also in a DGML format:
TechnologyExplorer Legend


The TechnologyExplorer.xml contains a configuration where you indicate the output folder.

  • The outputPath attribute specify the folder where the dgml files will be generated.
  • Each Include node specify a folder to traverse.
  • Each Exclude node specify a folder, and sub-folders, to not traverse.

TechnologyExplorer - Microsoft Visual Studio



One the xml file configured, just launch the TechnologyExplorer.exe!

Disable method step-into with debugger

The attribute DebuggerHiddenAttribute indicate to the Visual Studio debugger that the method is not debuggable, so you can’t step in.

public void DoThis()

Categories: C#, VisualStudio

Enhancing debugging experinence with Debugger Display Attributes

Have you ever wrote a class with a lot of properties/members and using the debugger was unefficient due to the among of stuffs showed and the lack of formatting of the informations?

Thanks to the attributes, you can decorate the members and properties to change the default apparence and behaviour in the debugger.

Let’s say that you wrote this simple class:

        public class Contact
            public Contact(string name)
                this.Name = name;

            public string Name { get; set; }
            public List<string> Properties { get { return; } }

            private List<string> properties = new List<string>();

Let’s use our newly created class:

        static void Main(string[] args)
            Contact c1 = new Contact("JF");

Hiding unwanted properties/members

You can see in the debugger that, the properties and Properties are in a way duplicated:

private List properties = new List();

Note that DebuggerBrowsable attribute is defined in System.Diagnostics.

As stated in the MSDN documentation, DebuggerBrowsable constructor take a DebuggerBrowsableState enumeration values. The 3 values defined are:

    Never indicates that the member is not displayed in the data window. For example, using this value for the DebuggerBrowsableAttribute on a field removes the field from the hierarchy; the field is not displayed when you expand the enclosing type by clicking the plus sign (+) for the type instance.
    Collapsed indicates that the member is displayed but not expanded by default. This is the default behavior.
    RootHidden indicates that the member itself is not shown, but its constituent objects are displayed if it is an array or collection.


You can also change the value formatting of every field/properties.

Imagine that you have a class and you want to have Count = 3 written without having to expand the class. you can use the Debugger display attribute to acheive it:

[DebuggerDisplay("Count = {count}")]
class MyClass 
    public int count = 3;

Categories: C#, VisualStudio

Visual Studio shortcuts

When there’s a selection:
   Ctrl-X : Cut the selection into the clipboard
   Ctrl-C : Copy the selection into the clipboard
   Ctrl-V : Replace the selection with the clipboard content

When there’s no selection:
   Ctrl-X : Cut the current line into the clipboard (Same as Shift-Del)
   Ctrl-C : Copy the current line into the clipboard
   Ctrl-V : Paste the clipboard into a new line (Same as Shift-Ins)

Ctrl-Z : Undo previous edition
Ctrl-Y : Redo the previous edition

Multiple clipboard buffers
You can copy or cut multiples times and use the Ctrl-Shift-V to circle into the clipboard buffer. Visual Studio remember the latest copy/cut.

Example: If you copy TEST1 and after TEST2. When you press Ctrl-Shift-V, TEST2 will be pasted. Press again Ctrl-Shift-V and TEST2 wwill be replaced by TEST1.

Ctrl-F : Show the find dialog
Ctrl-Shift-F : Show the find in files dialog
F3 : Go to the next occurence of the search
Shift-F3 : Go to the previous occurence of the search

Ctrl-F3 : Find the next occurence of the current selection.
Note: If there’s no selection, find the current word

Ctrl-/ : Select the Find box to make a search
Ctrl-I : Start a incremental search. Type and the first correspondance will be showed

Ctrl-] : Move to the matching brace
Ctrl-K + Ctrl-C : Comment the selection
Ctrl-K + Ctrl-U : Uncomment the section

Ctrl-Enter : Insert a blank line above the cursor
Ctrl-Shift-Enter : Insert a blank line below the cursor

Ctrl-Shift-Spacebar : Display the current parameter tooltips informations

Shift is used to select.

Shift-Left Arrow : Move the cursor to the left and extend the selection
Shift-Right Arrow : Move the cursor to the right and extend the selection
Ctrl-Shift-Left Arrow : Move the cursor one word to the left and extend the selection
Ctrl-Shift-Right Arrow : Move the cursor one word to the right and extend the selection

Ctrl-Shift-Home : Move the cursor to the beginning of the line adn extend the selection
Ctrl-Shift-End : Move the cursor to the end of the line adn extend the selection

Ctrl-Shift-PageUp : Move the cursor to the previous page and extend the selection
Ctrl-Shift-PageDn : Move the cursor to the next page and extend the selection

Ctrl-Shift-] : Move the cursor to the matching brace and extend the selection
Ctrl-A : Select the entire document

F7 : Switches from the design view to the code view in the editor
Shift-F7 : Switches from the code view to the design view in the editor

Ctrl-+ : Goes back to the previous location history in the document
Ctrl-Shift-+ : Goes forward in the navigation history in the document

Ctrl-F4 : Close the current document
Ctrl-TAB : Cycle through the opened MDI documents
Ctrl-Shift-TAB : Move to the previous MDI document

Document formatting
Ctrl-E + Ctrl-D : format the entire document
Ctrl-E + Ctrl-F : format the selection

Edition tips
F12 : Go to the defintion. Place your cursor on a word and press F12 to navigate to the definition of the word. You can place your cursor on a method, a class, a variable and F12 will open the file where the word is defined.

Ctrl-. : Show the contextual options of the word where your cursor is on. Try this: Type Car c = new Car();. Place you cursor on the Car and press Ctrl-., select Generate class for Car. Press F12 to go to the newly created class. You can use the same approach to create new methods/properties on a existing class. the Ctrl-. is a greate shortcut that boost your productivity. So play a little with this shortcut!!!

Ctrl-K + Ctrl-S : Show the snippet window allowing to choose a snippet you want to execute.
region example: To insert a #region tag, you select the text you want to be in the region and you press Ctrl-K + Ctrl-S, next you select the region snippet, press enter, type the region name and press enter.

foreach example: You can reduce the among of character you need to type by using the snippets. You can press Ctrl-K + Ctrl-S select foreach and press enter. This will create a foreach statement with the braces. By default, the variable type is var, you can leave it by pressing TAB. TAB go to the next parameter that you can customize. In this example, it place you on the variable name. You can type the name you want and press TAB to enter the collection name in which you want to loop.

Categories: VisualStudio

Code snippet

A cool feature in Visual Studio is Code Snippet. It automate redundant code that you need to write again and again.

For example, how many times do you write a for loop like this:

for(int i = 0 ; i < list.Count; ++i) { } [/sourcecode] You can insert a snippet with the keyboard shortcut Ctrl-K + X. This bring a context menu that you need to narrow the search and find the for snippet.

A quicker way is to type ‘for’ and press tab twice, which result in:

You can type your variable name to iter on, default is i. Press tab to go to the end condition and tape what you want.

Categories: VisualStudio

Visual Studio Tips book

There is a excellent book that provide tips on how to maximise the usage of the Visual Studio IDE. It provide a lot of tips on how to perform quicker operations on the editor and more.

The book name is : Microsoft Visual Studio Tips, 251 Ways to improve your productivity

That’s a really good book. I discuss some of the tips with other programmers at work and I was surprized that basic tips on the editor was not known by most of peoples.

Sara Ford’s blog

Categories: Book, VisualStudio