I have a unique situation. I am working on an open source library for sending emails. In this library, I need a reliable way to get the invocation method. I did this using StackTrace by parsing the StackFrame objects inside it. This works without problems in a debug-mode project where optimization is disabled.
The problem arises when I switch to release mode in which optimizations are enabled. The stack trace looks like this:
> FindActionName at offset 66 in file:line:column <filename unknown>:0:0 > Email at offset 296 in file:line:column <filename unknown>:0:0 > CallingEmailFromRealControllerShouldFindMailersActionName at offset 184 in file:line:column <filename unknown>:0:0 > _InvokeMethodFast at offset 0 in file:line:column <filename unknown>:0:0 > InvokeMethodFast at offset 152 in file:line:column <filename unknown>:0:0 ...
This is taken from unit test failure. On line 3 of this trace, I should see a method called TestEmail , which is defined elsewhere, but I believe the JITter inserts it. I read that you can prevent inlining by making the method virtual, but that will not work. Does anyone know of a reliable method to prevent the implementation of a method so that your method is detected in the stack trace?
c # inlining jit
Scott Anderson Mar 02 2018-11-11T00: 00Z
source share