Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging - skip code with a breakpoint

You know how you can click the yellow arrow on a breakpoint and drag it down to skip execution of lines of code? Well, is it possible to create a "When Hit" macro (or something similar) that skips execution of the line containing the breakpoint?

So instead of writing code like

if(!Debugging)
   Response.Redirect("LoginFail.aspx");

I could sit a breakpoint on the Response.Redirect() line and "When Hit" will skip it.

like image 306
P.Brian.Mackey Avatar asked Mar 24 '11 19:03

P.Brian.Mackey


1 Answers

I don't know of baked in way of doing this. You can however set the "When hit" options of a breakpoint to run a macro. It shouldn't be hard to write a macro that gets the current line, and then sets the next debugger line. You'll probably want to look at the Debugger.SetNextStatement method.

A macro like this should do it:

Public Sub SkipNextLine()
    ActiveDocument().Selection.LineDown()
    DTE.ExecuteCommand("Debug.SetNextStatement")
End Sub
like image 153
heavyd Avatar answered Sep 24 '22 10:09

heavyd