← All articles

Hiding Code From The Debugger

Tired of stepping through helper methods you already know work? The DebuggerHidden attribute tells the debugger to skip that code entirely.

Donn Felker

Donn Felker

2007.01.09 · 1 min read

Sometimes there are methods in code that my development department knows are robust. There are no bugs in the code. This might be helper methods that have been tested time and time again. Therefore we know we dont need to debug these methods 99% of the time. To alleviate the pain of stepping through unnecessary lines of code accidentally you can inform the debugger that it is not suppossed to access a block of code. To do this add the DebuggerHidden Attribue. You cannot set a break point in this block of code when this attribute is present.

[DebuggerHidden]
void DoSomething()
{
// Do Something
}

*Note: This is only valid on constructors, methods, properties, and indexers only.

Donn Felker

Written by Donn Felker

I've spent 25+ years shipping software, writing books, and running my own companies. I write about thinking clearly, working for yourself, and doing real work while AI rewrites the rules. New essays land here every week.

Get the newsletter

Keep reading