visual-studiovisual-studio-2017breakpointsvisual-studio-debuggingconditional-breakpoint

How can I change the location of a breakpoint in Visual Studio 2017


I've been looking over the internet to find out how to change the location of a breakpoint in Visual Studio 2017 and cannot find any answers. The only answer that comes close is from 2009 and is no longer an option in VS2017.

Most attempts to answer the question involve deleting and recreating the breakpoint. Most of the time that is fine, however if you're dealing with tracepoints or conditional breakpoints which have several options applied to the "breakpoint" you don't really want to delete and recreate it.

I've even seen requests on UserVoice to drag-n-drop the breakpoint to a different line, but nothing that tells me how to do it even without drag-n-drop.

Yes, I know a lot of people say why do you even want to move it? Well sometimes VS2017 just doesn't get that after doing a Get Latest from TFVC, the code has moved but the breakpoint hasn't moved with the code, and I really don't want to recreate the conditional tracepoints. Or maybe I just want to move it for general testing and debugging and focus on a differnt bit of code. Either way, it doesn't really matter why - the question is how.

So how do I change the location of a breakpoint without having to delete and recreate all the options?


Solution

  • Okay, so maybe I'm just blind, but it was not at all obvious to me.

    VS2017 Breakpoint Settings

    You see the blue text where it says Location: - that means you can click to edit! (Yes, just like you can click to edit the hit count or message string which are also in blue.)

    VS2017 Breakpoint Settings - edit Location

    And voila! We can now change both the line number and even the character position of the breakpoint without having to delete and recreate all the options (which is a pain if you have some complicated conditions or messages to output or a lot of breakpoints to move).

    Hoping this helps someone because not even the Visual Studio Documentation for Using Breakpoints mentions this!