Run To Click Debugging in Visual Studio 2017

You have many options when navigating through your code with the debugger in Visual Studio including setting breakpoints, stepping, and using Run to Cursor. In Visual Studio 2017 we have introduced Run to Click, a new way to more easily debug your code – point and click style. You no longer need to set temporary breakpoints or step several times to execute your code and stop on the line you want. You now can get all the benefits of Run to Cursor (Ctrl+Shift+F10) without searching through the context menu or taking your hand off the mouse for a two handed shortcut combination. Run to Click works while debugging in any programming language in VS including C#, VB, C++, and Python.

Point and Click Debugging

When stopped at a break state under the debugger, a light green “run execution to here” glyph subtly appears next to a line of code where your mouse is hovered.

RunToClickICONOff

Move your mouse to the glyph and click the button. Your code will run and stop on that line the next time it is hit in your code path.

RunToClickICONOn

This is especially useful if you naturally have one hand on the mouse while debugging to inspect variables with data tips in your code. You can quickly Run to Click a line of code, inspect the variables on that line, and then continue debugging all while keeping focus and attention in that location. Run to Click between the same method, different methods, and within loops!

RunToClickBasic

Special Notes

Remember that Run to Click will run the execution of your application that you are debugging until that line of code is reached.

  • If you click on a line of code that won’t be hit, the application with finish executing.
  • If you click on a line of code that resumes the application waiting for additional user input, once that code path is triggered by the input, you will break where you performed the Run to Click.
  • If you Run to Click on a line and the execution path triggers a breakpoint, the debugger will stop at any breakpoints in the path. When you hit “continue” (F5) execution will continue and you will stop on the line where you triggered run to click (just like if you had set a breakpoint on that line).

You can turn off Run to Click from the checkbox Debug/Options/Enable Run to Click.

Wrap Up

Run to Click improves your productivity by helping you get to the code you want to inspect faster. Try it out by downloading Visual Studio now (https://www.visualstudio.com/downloads/) and let me know what your think! We are always wanting your feedback so drop your questions and comments in the section below, or tweet @VS_Debugger.

23