A pattern you'll find in the .net base class library is that of the ThrowHelper. In essence it cuts down the amount of byte code per method.
Anyway, I was wondering if there was an attribute directive to stop an error caused in the throw Helper from stopping inside the helper. I'd prefer the debugger to stop at the calling line.
i.e.
ThrowHelper.ThrowAnException ()
rather than inside ThrowAnException()
You can also mark your throwing method with an attribute:
class ThrowHelper
{
[DebuggerStepThrough]
public static void Throw()
{
throw new InvalidOperationException();
}
}
Then debugger will not enter this method.
You could make the helper method not actually throw the exception, just create it. The stack trace will point to the throw statement in your real method, not to anything in ThrowHelper.
throw ThrowHelper.CreateAnException();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With