Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: how to hide a method from the stack trace?

I have a dead simple one-liner method that I don't want to see in the stack trace: is that possible? maybe mark it with an attribute?

Just to clarify, I'm not trying to print the trace, or rethrow, or have auto step-through in the debugger. I'd like the method to not show up in the trace in the first place, because the trace is then handled by some third-party code. I want control at runtime, I'm not interested about debugging. I'm saying this because most of what I've read on StackTrace seem to be about these topics.

like image 350
benblo Avatar asked Apr 21 '10 09:04

benblo


1 Answers

This can only be done when your method is inlined. Either the JIT does it, or you do it yourself (change the code). The JIT however, is pretty conservative about inlining methods and practically only does that when the method is very small, or when the method is used in a loop.

like image 196
Steven Avatar answered Oct 08 '22 15:10

Steven