I'd like to avoid the debugger breaking into a series of validation helper methods that may lead to an exception, If an exception is thrown I'd like for it to appear at the point of invocation, not inside these helper methods. So I put the DebuggerStepThroughAttribute on the helper methods. However, as the validation methods may have bugs, I'd still like to be able to debug the validating method. If I place a breakpoint inside one of these validation method, the debugger still will skip right over it.
How can I get it so that with an exception is thrown the method is skipped, but if I place a breakpoint in the method, then I should be able to step into it, or is this not possible?
Putting DebuggerStepThroughAttribute
on a method prevents you from stepping into it using the debugger. Contrary to what you say in your question, you can still place breakpoints inside the method and they will be hit. The MSDN docs for the attribute state this as well.
This is the closest you are likely to get to what you want (eg. step through the method normally, but place a breakpoint on its first line when you want to debug it).
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