This article will let you know 15 features or you can say tips and tricks of VS2010 IDE.
1. Call Hierarchy
Place below methods in .cs file
private void Method1() { Method2(); }
private void Method2() { Method3(); }
private void Method3() { //Dosomething }
Now right click on Method2 you will get below View Call Hierarchy option like below shown.

On selection ofView Call Hierarchy option, a tree like structure will appear like below which provides the details like from where particular method is being called and which methods that particular method calls.
On the right hand side of the below image you can see the file details.

Note: If you add any new method and the call hierarchy output window is already open and you opt to View Call Hierarchy again, the Call Hierarchy output won't be refreshed. You need to select Remove Root like shown below and select View Call Hierarchy again.
2. Zoom
Now code or text can be zoomed in and out by pressing the control key and moving the scroll wheel of mouse.
3. Generate Class
Now initialize MyClass inside Method2 like below which does not exist.
public void Method2() { Method3(); MyClass myClass = new MyClass(); }
You will get error because class does not exist. We can use Generate Class feature like shown below.

Click on Generate Class for option and class will be created for you.
4. Box Selection
Declare three private variables like below.
private int pr1; private int pr1; private int pr3;
Now press ALT and drag the mouse on all three private keyword for selection like below.

Now start typing public and you will notice all selected private are chaning to public.
5. Generate From Usage.
You can create properties and methods without leaving the code where you are currently.
In third tip we discussed about how to Generate class, now we will create property and methods.
i) Access property in Method2 from myClass which does not exist in the class like below.

You will get error as Property does not exist in the class so we can create property like shown below.

ii) Access method in Method2 from myClass which does not exist in the class like below.

You will get error as Method does not exist in the class so we can create method like shown below.

You can read more about Generate From Usage here
6. Navigate To
You can search for files, types and member using NavigateTo.
Presst Ctrl + Comma(,) to launch NavigateTo window.
i) Simple search - Search for Default and you will get 6 results as shown below.

ii) Multiple word search - Now type "Default aspx" in the search and you will get only 3 results. In this case Navigate To searched for both Default and aspx. Default and aspx need to be seperated by space.

iii) Pascal Case Searching - Built in methods and classes follow pascal naming convention. In pascal casing each word of class name or method name will start with capital letter. In my tips 5 i had created a method MyMethod which is the search result like shown below.

7. Pin Data while Debugging - 1
Pin while debugging will help you to get rid of placing cursor on the variable of for loop to check the value. The pin feature will pin the variable right next to for loop so that you don't need to keep mouse on variable to see the variable value as tooltip.
Create a for loop where we would like to check the variable value like shown below.

Now when you loop through the for loop the variable, you can see the value in pinned variable.

One can put comment also on pinned variable while debugging like shown below.

8. Pin Data while Debugging - 2
We can also use pin while debuging to store the variable value of last debugging session.
Pin the value of variable like below

Now stop debugging and remove the break point and run application again. You will see the last pinned variable value like below.

9. Dependency Graph or Sequence Diagram
Refer VS2010 - Sequence Diagram
10. Improved Intellisense
i)Now if any character matching in the intellisense will be highlighted. As shown below I typed only st, all the property containing st listed out.

ii) Pascal Case Intellisense
VS2010 pascal casing intellisense helps to search type and member using the capitalized letter of type and members like shown below. When I entered BC, VS2010 intellisense filtered it to BackColor and BorderColor.

11. Conditional Breakpoint
We always get into situation where we want to debug for certain condition in large amount of data. VS2010 provides option to debug the program in specific condition.
Put a breakpoint on the line where you want to put condition and right click on the red dot and you will get the option like shown below.

Now click on the condition option and you will get window like shown below to enter breakpoint condition. Intellisense works in conditional breakpoint window.

Now run the code and breakpoint will hit when value of i is 5.

12. Supports Multiple Monitor
VS2010 allows multiple monitor support by allowing tools window, editors and designers moving outside the top level window which enables to move or position these windows anywhere you want.
Double clicking or dragging editor window or tool window will dock these windows out of the top level window like shown below.

You can put it back using Dock as Tabbed Document as shown below.

13. Multiple Editing
Say for example I had given variable name of List variable as lstTest then I realized it should be lstEditing.
Change lstTest to lstEditing and now you will get option change all the occurence to rename from lstTest to lstEditing likd shown below.

14. Refactoring using Extract Method
Extract method of VS2010 is very useful and handy feature to create new method within the code.
Select the lines of code which you want to be extracted and put it in new method. Now right click to get option of Refactor and then select Extract Method like shown below.

Once you choose Extract Method you will get the screen shown below to provide new method name.

Now click Ok and the code will be reactored as shown below.

15. Improved javascript intellisense support
I am giving reference of wonderful article by Scott Guthrie on JavaScript Intellisense Improvements with VS 2010
This ends the artilce of 15 tips of VS2010 IDE.
|