Share via


Visual Studio 2013: Working with Breakpoint Labels

 

NOTE: This is an older feature. I’ve updated the information for VS2013.

 

The Breakpoints Window has supported adding labels since VS2010, however most people aren’t aware of this feature. But how does this help you?  Well, first, you can put friendly names for Breakpoints to make them easier to understand.  Second, you can sort by the label names.  And, third, you can search the labels when you have a lot of Breakpoints.  Let’s see how to make this happen.

 

 

Creating Labels (Friendly Names) for Breakpoints

Go into any code base and create several breakpoints (F9) then open the Breakpoints Window (CTRL+ALT+B):

5-16-2012 12-12-28 PM

 

 

Notice the Labels column? It goes largely ignored unless someone points it out. To add a label to a single breakpoint just Right-Click it and choose Edit Labels:

5-16-2012 12-17-06 PM

 

Alternatively, you can select multiple breakpoints and do the same thing to create labels in bulk:

5-16-2012 12-19-56 PM

 

For this demo, select about half (or a little more) of you breakpoints and edit their labels. This will bring up the Edit Breakpoint Labels dialog:

5-16-2012 12-22-03 PM

 

Put in a label of “cart” to indicate these breakpoints are associated with our shopping cart and click add:

5-16-2012 12-23-25 PM

 

 

It turns out that these particular breakpoints are also associated with adding items to the cart so let’s put in another label of add item:

5-16-2012 12-25-21 PM

 

The point here being that you can add multiple labels to breakpoints. Click the OK button and notice the result:

5-16-2012 12-27-01 PM

 

Let’s assume the rest of the breakpoints deal with deleting items from the cart. Select them and edit the labels:

5-16-2012 12-30-25 PM

 

Since “cart” is already in our list of breakpoint labels we can simply select it:

5-16-2012 12-31-55 PM

 

Now we just add “delete item” to the list and we are all set:

5-16-2012 12-32-49 PM

 

Click OK and verify all the breakpoints have labels:

5-16-2012 12-35-08 PM

 

 

 

Sorting Breakpoints by Label

Now that we have set the labels we can sort by the labels column entries by click on the column header:

5-16-2012 12-39-06 PM

 

Everything looks in order but let’s make a change. Edit one of the “add item” entries to read “modify item”:

5-16-2012 12-42-37 PM

 

Take a look at your list again and notice how they are sorted:

5-16-2012 12-43-19 PM

 

The labels are sorted alphabetically from left-to-right so pay attention to your label names. In this example we have a potential issue since the word “cart” is keeping the sort from happening the way we want it. Fortunately for me, since they are all related to the cart, I can safely turn off the “cart” word and still have contextual meaning for my labels:

5-16-2012 12-52-50 PM

 

 

 

Searching Breakpoints by Label

Now that we have good labels set up we can do more advanced activities. We can search by any column but searching by labels we designate is particularly powerful. For demo purposes I’m going to make a point about searching you need to pay attention to. We want to find all the “add item” breakpoints. Click in the search box and type the letter “a” and press Enter:

5-16-2012 1-02-47 PM

 

As you can see it did not filter as expected. This is because the In Column value is set to All Visible. Since the letter “a” appears somewhere in every breakpoint we need to tell search to only pay attention to the labels column:

5-16-2012 1-05-57 PM

 

This results in getting the desired outcome:

5-16-2012 1-09-15 PM

 

To clear the search criteria just click the Reset Search Criteria button:

5-16-2012 1-12-10 PM

 

All the breakpoints will come back:

5-16-2012 1-14-13 PM

 

 

 

Finally

You can do many great things with this feature so experiment and see if it is valuable for you. There are a lot of great things you can do with breakpoints and this is only the tip of the iceberg. I’ll discuss other features in a future article.

Comments

  • Anonymous
    August 26, 2013
    Thanks!  As you mentioned, I never noticed the "Labels" column. The only reason I can come up with for why i never noticed it is that there's nothing in the column, and the column dividers don't stand at all.

  • Anonymous
    August 26, 2013
    Hey Greg :) Yeah I call it the "ninja column" because people just never see the thing until someone points it out. Z

  • Anonymous
    August 27, 2013
    Very useful with much  BPs Thank you

  • Anonymous
    January 28, 2015
    Discovered this late but will make great use of it going forward.

  • Anonymous
    January 29, 2015
    Thank you. It is year 2015 and it is now when I came across these cool observations. Keep it up Greg.

  • Anonymous
    February 18, 2015
    This is indeed a good idea to use in the future. I just found out about it and now read this article. Good job! Thnx.