DebuggerStepThroughAttribute

by michel 10. October 2008 16:01

I love to check out somebody else his or her code. I always learn something from it. Just a couple of days ago I had an example from Scott Allen about WWF and ASP.Net.

In his code example I found a class with different small data checks. Each static method was decorated with the ´DebuggerStepThroughAttribute´.

public static class Check
{
    [DebuggerStepThrough]
    public static void IsNotNull(object argument, string message)
    {
        if (argument == null)
        {
            throw new InvalidOperationException(message);
        }
    }
}
Scott Allen, source code example

 

Not exactly knowing what the attribute meant (besides what the name is telling you) triggered me to ask it Google :)

By placing System.Diagnostics.DebuggerStepThrough attribute above a method, you instruct the debugger to step through that method and not into it. With other words this instruction will cause the debugger not to step into method as normal, but you can always place a breakpoint in that method and stop there.

Hmm sweet isn't it :) Hopefully it's useful for you as well.

[kickit] 

Tags: , , ,

C# | Debug

Comments are closed

About the author

Michel TolMy name is Michel Tol. I'm a developer specialized in .NET technologies. Mainly focussing on SharePoint Technologies and web development. I am Certified Technology Specialist for MOSS 2007 -  Configuration, .Net Framework 2.0 - Web applications and Biztalk Server 2006 - Custom Applications.

View Michel Tol's profile on LinkedIn

  

E-mail me Send mail

Page List