I've written a logger/exceptionfactory module, which uses System.Diagnostics.StackTrace, to get attributes from calling methods and their declaring types. However I noticed, that if I run the code outside of Visual Studio in Release mode, some of my shorter methods get inlined and missing from the stack trace. Now I have no way to test whether a method will get inlined in runtime, but I do not want to [MethodImpl(MethodImplOptions.NoInlining)]
every important method. But if a method from my base classes will be missing because of it, I can misread the layer and operation information and that could lead to false log or misparameterized exceptions.
Is there a rule of thumb what gets inlined where and when? Are virtual methods, static methods, base class methods treated any differently? Do I only have to worry about inlining inside assembly? Inside namespace?
Yes, there are some rules but they are heuristics used by the JIT compiler and these heuristics can change at a moment's notice.
Some of the heuristics for "heavy" that I'm aware of:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With