What can be done to skip through the parts of code when stepping through code? I find this particularly annoying when the debugger jumps to property gets and sets. Is there way to avoid this?

+5  A: 

there's an option Step over properties and operators (Managed only)

or use F10 instead of F11 (with default keyboard binding)

Andreas Niedermair
That option is not available in VS2005.
Craig Johnston

You could use "run to cursor" for one time breakpoints.

+1  A: 

Yes, there's a step over (F10) function, as well as a step into (F11).

And also Step Out (ctrl-F11) (continue until you have returned to the immediate calling function).

When you used F10 the code simply steps over each statement unless you've set a break point in a deeper level. I've never found the debugger miss behave the way you've suggested , mind you I'm only using VS2008.

+7  A: 

If you want to skip an entire method you can mark it with the DebuggerStepThrough attribute:

public void SomeMethod()
    // lots of code...

public int SomeProperty
    get { return ComplexLogicConvertedToMethod(); } 
    set { this.quantity = value ; }

Note that the attribute prevents the debugger from stepping into the method or property, but you can always place a breakpoint in that method and stop there1.

The attribute comes in handy especially when you have code like this:


If you want to step into DoSomething and press F11 you will - without the attribute - first step into SomeProperty and then into DoSomething. With the attribute however, you end up immediately in the DoSomething method.

1If you want to completely prevent users from placing a breakpoint into a method you can use the DebuggerHiddenAttribute.

Not awarded because did not mention F10.
Craig Johnston

You can set the attribute DebuggerStepThroughAttribute on any methods/properties you don't want to step into.

And you can also use the "Step Over" rather than "Step Into" command.


Add DebuggerStepThrough attribute to your property:

private static void DO() {
Alex Veremeenko