Tuesday, 6 April 2010

New Code editing and navigation features in Visual Studio 2010

Visual Studio 2010 is packed full of new features for the developer. In this post, I will focus on those that are of immediate benefit for code editing and navigation.

I recently reported on TechDays 2010 in Helsinki where I presented on (amongst other things) Visual Studio 2010.

So it's about time I shared some of the goodies with the online community.

Visual Studio 2010 is packed full of new features for the developer. In this post, I will focus on those that are of immediate benefit for code editing and navigation.

I'll begin by creating a new ASP.NET Web project although I could have created a Windows Forms or WPF application. It doesn't matter for this demo.

 
I have added a Button named buttonSend and a Label named labelMessage.
Inside the button's Click event handler, let's say I want to assign a value to the Label. Furthermore, perhaps I am not sure of it's name and am relying on intellisense to help me.
It might begin with lblxxxx or then again I might have begun with the prefix labelxxxx. However, I know that it contains Message. So I can simply type mes and then wait for intellisense to figure it out.

 
Intellisense is now able to use sub strings which is a great feature.
Now let's say that I have added a method called ChangeText that I call from my button's Click event and I want to call it from the Page_Load event also.


 
Now you have to pretend for a moment that you can't actually see the Page_Load event and that there are perhaps hundreds of lines of code here.
Well, no problem. We have another great feature called Quick Search.
Pressing Ctrl and a comma "," opens it up.
I could have searched for "Page" or even "Page_Load". Instead, I tried "PL".

 
That's right. Quick Search understands Pascal notation and so could have let me find LoadCustomerOrderItems by entering a search string on "LCOI".
Aside. I did consider contriving a method name that had a risqué Pascal search string but thought better of it.
Now let's say that I have invoked my ChangeText method from several locations in my code.
One useful feature allows me to simply click on the method name where it is declared and every calling statement is highlighted.


 

This new feature is called Visualization and is a nice touch. However, most times the calling statement isn't within a couple of lines of the method itself.

Time to roll out the Call Hierarchy feature.

Right click the method name and select View Call Hierarchy.




The resulting Call Hierarchy window displays every call to this method. It can even show you the actual line of code that makes the call and it's location.

 
Put all of these features together and you are likely to be much more productive when coding in Visual Studio 2010.
Now you are probably thinking that these features are absolutely brilliant and things couldn't possibly get any better.
Well you would be wrong.
There is an editor feature that is the single most useful feature to be added to Visual Studio since I had hair.
And I am not going to tell you what it is.
Not tonight at least.
I will tell you tomorrow.
Be warned though. It has to be the best Visual Studio code editor feature EVER !


See you soon

Phil Stirpé
"I don't do average!"





No comments:

Post a Comment