Stop inlining…


If you want to prevent a method from being inlined, add:


[MethodImplAttribute(MethodImplOptions.NoInlining)]

Comments (3)

  1. Maurits says:

    Hmm… why? To test performance with and without inlining?

  2. A good candidate for not using inline is when you want to call a delegate and you want to make sure than no one is updating the invocation list – what that you do in such action is to create a method that has noinline that gets the delegate and return it (remember its immutable) that way you make a copy of it automatically 🙂

  3. Shawn B. says:

    Great but how about a way to force inlining? There are indeed times when I know better than the compiler and JITer and know a great deal about what I’m doing.

    Thanks,

    Shawn