.NET debugging made easier

Not sure about you but I was not aware of the existence of the DebuggerStepThroughAttribute. Debugging code can be difficult at times and any tool or mechanism that can ease this pain is always welcome.

As far as the CLR is concerned, there is no semantic attached to this attribute. However Visual Studio does not step through methods or classes that are decorated with this attribute. Although you could still use breakpoints in those methods or classes, they are never hit.

And here is how breakpoints would look in Visual Studio 2008:


This attribute can be applied to methods, property accessors, classes and structs. I found it to be extremely useful when I wanted to step through a method without first stepping through all property accessors used as parameters or the source instance of the method. In the example below, a.Value and b.Value are not stepped through when pressing F11 in Visual Studio. It is only the Add method that is fully debugged:

var a = new SomeValue(10);

var b = new SomeValue(150);


Add(a.Value, a.Value);

class SomeValue




  public int Value



    get { return value; }




Comments (16)

  1. Chris says:

    I am a big fan of this attribute.  If you want to stop at a breakpoint set in a method decorated with this attribute there is an option.  In visual studio 2008 (I believe it is in the same place in 2005) under Tools | Options | Debugger | General uncheck "Enable Just My Code (Managed Only)" and your breakpoint will still trip.  If you attempt to step into the same method without the breakpoint you will still glide over.

  2. Mike Read says:

    Thanks very much, this will speed up debugging considerably

  3. Lito says:

    I read about this moons ago.  Then when I got fed up with the debugger stepping over all the properties I I thought I should give it a try.  Alas, I could not remember it.  I asked about but did not really get the answer I was looking for.  Thanks for bringing it up.

  4. ghill77 says:

    I don’t really like the fact that you have to flag each property that you want to skip.  There should be some other directive to just skip all property accessors.

  5. Rory says:

    This might be new to 2008 or even sp1 (I dont remember seeing it in 2005) but the context menu for the code window now has two items during a debug session that can help with just this sort of thing. The first is a "Step Into Specific" submenu that shows each of the method calls made by the current line. The other is a checkable "Step over properties and operators" option that does just as the name suggests (VS prints a message in the output window if you step over a property with it enabled). I’d try using them before the attribute, simply because you don’t have to modify the code just for debugging (or remember to remove it when you’re done).

    Hope it helps

  6. Schneider says:

    I have also removed these attributes to aid debugging. (The designers add these by default)


  7. Rory says:

    I just remembered that the c# preprocessor directives "#line hidden" and "#line default" can be used to produce the same effect as this attribute, the debugger will treat any code between the two directives as if it doesn’t exist. Again, I wouldn’t do this without a really good reason, but it can be useful when creating a code generator that needs to hide some mess from the developer at debug time.

  8. Aaron says:

    Should it not be called DebuggerStepOver though? It is technically not stepping through that code.

  9. ihath says:

    thanks for sharing. That is so useful

  10. this attribute is basically ideal for custom debugger helper methods such as custom assertion methods, exception handling methods, etc. etc. etc. as well as source code generation for which you don’t want get the hell confused out of consumer developer…

    anyway, by VS2008 you’ve also got the <b>DebuggerStep over properties and operators (Managed only)</b> option which I personally most of the time make it disabled 😀

  11. Ashley Dickson says:

    NetBeans can step over and into within a line, very nice.

  12. Art is the process or product of deliberately arranging elements in a way that appeals to the sense or

  13. Art is the process or product of deliberately arranging elements in a way that appeals to the sense or

  14. dan says:

    More like DebuggerStepOverAttribute than step through.

  15. Hey this is really good stuff. Actually been waiting for such thing.

    Keep sharing these and help people in the community.



Skip to main content