.Net tricks I’ve learnt this week
Ever wanted to write code that you want executed while testing/debugging but didn’t want built into you production/release mode code?
Just pop the [Conditional("Debug")] attribute to your class or method and it won’t get compiled into your release version.
Nice and simple!
Also, do you get sick of debugging through superflous methods (eg. dumb constructors, etc) when stepping through your code just to get to the meaty stuff that you’re really interested in?
Stick the [DebuggerStepThrough] attribute on the class, property or method you want to skip over. It’s like automatically telling the debugger to step over and not step into.