Skipping a Method when using Debug Step-Through

It’s an attribute (decorating), not a preprocessor directive, that allows you to skip a well-tested method when you are using F11 to step-through your code.

THE PROBLEM
When using F11 to step through your code in debug mode, you often go into helper routines that are well-tested and won’t have errors. Wouldn’t it be nice to skip over these? Wouldn’t that speed up your debugging – or at least make it less boring?

THE SOLUTION:
Add the “DebuggerStepThroughAttribute” before the method you want to skip.

Below is a simple routine I often use that adds a Slash to a path name, but only when it doesn’t end with a slash. It works, so I never need to walk-into it. (I guess I could also put it in a common library.)

<pre>
        [DebuggerStepThroughAttribute()]
        public static string EndsWithOneSlash(string pathname)
        {

            // make sure we have one slash at the end of a path
            if (!pathname.EndsWith(@""))
                pathname = pathname + @"";
            return pathname;
        }
</pre>

Uncategorized  

Leave a Reply