Monday, October 6, 2008

.Net System.Diagnostics.DebuggerStepThrough Attribute

Sometimes when you are running your code in debug mode, you don't want to stop in some methods, maybe because you already know that this method will always return what you want, because is not so important for the job you have in hands, or some other reasons... That's where the DebuggerStepThrough comes in. The compiler will add the necessary metadata preventing the debugger to step into the method. Even if you have this attribute defined, you can stop in, if you define a breakpoint there.

public string Name {
[System.Diagnostics.DebuggerStepThrough]
get { return name; }
}

0 comments: