Reputation: 488
The answers and comments in the following questions provide conflicting information.
How to get the name of the current method from code
Can you use reflection to find the name of the currently executing method?
It is not mentioned in the documentation as well.
https://msdn.microsoft.com/en-us/library/system.reflection.methodbase.getcurrentmethod.aspx
Upvotes: 2
Views: 472
Reputation: 2721
No, the JIT compiler is free to inline the method.
You'll need to add the [MethodImpl(MethodImplOptions.NoInlining)]
to any method that calls GetCurrentMethod()
to prevent it from being inlined.
If you're only interested in the method name, CallerMemberNameAttribute
is much easier to use.
Upvotes: 1