Sunday, March 17, 2013

Debugging In VS 2012

Visual Studio have brought some new facilities which makes the developers to debug their code in a more effective manner. Thought of blogging some of some fancy features which seems very tiny things but makes our lives easier.

1. Labeling Break Point

Now you can add labels for your break points which in a way supports to categorize the breakpoints. By using this features we can enable or disable list of break points as we want based on the category.
You can write click on a break point & then click on Edit Label.
image







Then you will get the following dialog where you can add the label. It will list down the existing labels so that you can reuse it.
image
After you label your breakpoints you can get the list of breakpoints in your solution in the breakpoint window. Breakpoint window can be found in
Debug –>Windows->Breakpoints.
Now VS 2012 have this fancy featues where we can search any tool using the quick search. If you all are not sure about where exacly the tool if just type the tool you need in the quick search box VS will find it for you. Quite Cool :).
image
In the breakpoint list you can see the breakpoints with the labels so that the developer can enable or disable them based on the debugging context.
image

2. Conditional Breakpoints

Suppose you have a for loop in your code where you want to debug & see the code of the 17th item in the collection of which your are iterating. In the previous VS versions we have to debug the code iteratively until it reaches the 17th item. No need to go it to that hassle anymore VS 2012 has come up with the new feature which give the developer the facility of adding conditional breakpoints. So that the breakpoint hits when the condition is true only.
Right click on the breakpoint & then select condition.
image
Then you can add the condition you want in to the dialog box.
image
Then the breakpoint will only hits when the i=17. No need to iterate through the whole collection on debug.

Happy Debugging.

2 comments :

  1. Its Interesting ... But need VS2012 right?
    Can't we use this in VS2010 ?

    ReplyDelete
    Replies
    1. Most of the functionalities are available in VS2010 ultimate version as well.

      Delete