New IDE Features in Visual Studio 2010 for C# Developers

After a quick review of C# language features, let’s do the same for the IDE improvements. So, what’s in there for C# developers?

Generate From Usage

This feature greatly improves Visual Studio support for test-driven development (TDD). However, it is useful even if you don’t use TDD at all. It might increase your productivity by simply reducing the number of keystrokes and eliminating repetitive typing. For example, now I can write code like this:

class Program
    static void Main(string[] args)
        var test = new SampleClass(firstParameter: "test", secondParameter: 0);
        test.FirstProperty = 1;
        test.SampleField = 2;
        int value = test.SomeMethod(100);

SampleClass doesn’t exist at this moment, so everything is going to be highlighted as an error. But instead of typing all the declarations, I set the cursor on the highlighted error, press CTRL + “.” and have the IDE generate code for me.


Visual Studio 2010 can generate classes, constructors, properties, fields, enum members, and methods (and it uses the names of optional parameters from the constructor or method calls). Just look at how much code I didn’t have to write. All this was generated by simply pressing CTRL + “.” several times.

class SampleClass
    private string firstParameter;
    private int secondParameter;
    public int SampleField;

    public SampleClass(string firstParameter, int secondParameter)
        // TODO: Complete member initialization
        this.firstParameter = firstParameter;
        this.secondParameter = secondParameter;

    public int FirstProperty { get; set; }

    internal int SomeMethod(int p)
        throw new NotImplementedException();

However, sometimes IntelliSense, which is so nice when you’re dealing with already-defined classes, may get in your way when you try this “generate from usage” approach. For example, suppose that I want to add another property to SampleClass and call it First. Since I already defined FirstProperty, IntelliSense autocompletes First to FirstProperty when I type “=”.

To avoid this problem, press CTRL+ALT+SPACEBAR to switch to IntelliSense suggestion mode (as opposed to completion mode). In suggestion mode, IntelliSense is less aggressive – it doesn’t autocomplete member names after you type an equal sign or open parenthesis or something like that. But you are still able to choose an existing member from a list if you need to complete the member name.


Check out Generate From Usage and List Members topics on MSDN to learn all the details about this feature.

Call Hierarchy

The new Call Hierarchy window helps you analyze your code and navigate within it. I opened one of the LINQ sample projects that come with Visual Studio. (Click Help and then Samples on the Visual Studio menu to get the list of samples.) I chose the WebServiceLinqProvider sample, since it’s a fairly big one.

Now, to open the Call Hierarchy window, I can put the cursor on any method, property, field, indexer, or constructor, no matter whether it’s a declaration or an actual call, right-click it then and click View Call Hierarchy (or press CTRL+ALT+K). Call Hierarchy is also available if you right-click a member in the Object Browser or in Class View.


For me, the biggest advantage of this window is that under the Call To node you can see which members call the selected member, and where those members are. This information is often hard to get and analyze, since member calls are usually scattered across the project.

In the same window, under the Calls From node, you can also see which members the selected member calls. For virtual and abstract members, you can see the overrides.

What’s cool is that you can navigate from this window to the code you want to look at in more than one way. First of all, you can see what the method call looks like in the Call Sites column. You can also see the name of the file that contains this code.


Second, you can double-click any method call and Visual Studio will open the method for you.

But if you want to still see the method you are analyzing, there’s third way. Open the Code Definition window and move it so you can also see the code editor and the Call Hierarchy window. (The best place would be a second monitor, and this is now easy to do with all these undockable windows, thanks to the new WPF UI.) Now if you click on a method call (instead of double-clicking), you can see the corresponding code in the Code Definition window, without losing your position in the main editor.

Don’t forget to check out the shortcut menu, which allows you to use such commands as Go To Definition, Find All References, and Add as New Root for each member.

Speaking of navigation improvements, the next cool IDE feature is a quick search tool for symbols. Just press CTRL + “,” (or click Edit and then Navigate To) to see the new Navigate To window. You can search for types, members, and files in this window. Camel-case search is supported as well. Everything is displayed in one result list. In the following screenshot, you can see a class, a constructor, and a file whose capital letters match my search request. And it goes without saying that you can navigate to any item with a simple double-click.


Reference Highlighting

This is one of those subtle features that just make things better. If you put the cursor on a symbol (method, property, variable, etc.), all instances of this symbol are automatically highlighted in the code editor. You can also navigate from one instance to another within a file by pressing CTRL+SHIFT+UP/DOWN ARROW. How to: Use Reference Highlighting on MSDN describes how you can configure the highlighting color and turn on/off the feature (it’s turned on by default).


Box Selection and Multiline Editing

Suppose that you want to change several fields in your class from public to private. And you have a couple dozen of those. Now you change the declaration by typing public just once. Press ALT and then use your mouse or arrow keys to select the box area (in my case, the column that contains the private keywords).


Now simply type the new text and it will be repeated on each line. Check out this nice video from the Visual Studio Editor team, which shows more scenarios where this feature may come in handy (adding comments, writing repetitive code, etc.).

Docking Windows and Zoom

I already mentioned that moving Visual Studio to WPF helped to improve multiple-monitor support. In fact, you can undock any window and rearrange everything according to your needs. Dock windows to the edges of the main window, or simply leave them in the middle of the screen if you want.

Another useful feature enabled by WPF is zooming. Press CTRL and use your mouse wheel to enlarge or decrease your font size. The C# team does a lot of presentations, and I can tell you that it’s much easier to give (and see) a demo now.

Extension Manager

If you’re still looking for ways to improve your IDE, try one of the numerous add-ins developed by the community and other companies. In this release, Visual Studio greatly improved its SDK for add-in developers. Also new is the Extension Manager, which helps you to easily download, install, and uninstall Visual Studio extensions. You can get to it by clicking Tools and then Extension Manager.

Now you can search for add-ins online without leaving the IDE. The Extension Manager checks for add-ins and their updates at Visual Studio Code Gallery.


What Else?

No, this is not all that’s in there for you. I just mentioned the most popular features that might be useful to any C# developer, no matter what technology or API you use.

There are a lot of subtle improvements that might be hard to notice. For example, error highlighting now works in more places. Another example is IntelliSense, which now supports camel casing and filtering in all of its lists.

Also, a lot of enhancements are specific to certain technologies: Office development, WPF, Silverlight, SharePoint – just to name a few. I also didn’t mention improvements in the debugger or application lifecycle management .

Instead of providing tons of links, I’ll provide just one: Visual Studio 2010 Product Highlights. This document briefly describes major Visual Studio improvements and provides all necessary links to relevant MSDN docs.


Special thanks to Kirill Osenkov, Alan Berman, and Mick Alberts for reviewing, editing, and providing helpful comments.