Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I step into a method decorated with DebuggerStepThroughAttribute?

Tags:

c#

debugging

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?

like image 650
Michael B Avatar asked Nov 06 '22 05:11

Michael B


1 Answers

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).

like image 150
adrianbanks Avatar answered Nov 09 '22 23:11

adrianbanks