Preventing JIT inlining on a method

You could use MethodImplAttribute and specify MethodImplOptions.NoInlining.

[MethodImpl(MethodImplOptions.NoInlining)]
void YourMethod()
{
    // do something
}

Note that this still doesn’t guarantee that you can get at the actual calling method as seen in the source code. Your method won’t be inlined, but your method’s caller could be inlined into its own caller, etc etc.

Leave a Comment

tech