Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can the .NET JIT compiler inline methods that are decorated with attributes?

If there is an attribute (any attribute),there is probably a reason, so in theory, it shouldn’t be inlined but it’s just a guess.
Do I have to use [MethodImpl(MethodImplOptions.NoInlining)] if I want to suggest I don’t want Inlining?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Attributes in general? sure; however, both the compiler and JIT are free to pay special attention to anything in System.Runtime.CompilerServices, and apply special rules (well, technically they can pay special attention to anything at all, but the relevant types tend to be there; counter-examples would be [Obsolete] and [Serializable], which are not in that namespace but which have special rules). [MethodImpl(...)] is one of those attributes with special rules for the JIT.

Attributes in the general sense, however; make no real difference.

Yes, [MethodImpl(MethodImplOptions.NoInlining)] requests that the JIT should not inline this.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading