I guess so!
EDIT: The motivation for this question is: It seems to me that due to the semantics of static constructors they could never be safely inlined.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The jitter’s inlining strategy is an implementation detail — subject to change at any time — so there are pretty much no guarantees about what can or can’t be inlined.
Having said that, it’s difficult to see how a static constructor could ever be safely inlined, bearing in mind the guarantees provided by the C# and CLI specs regarding static constructors and type initialisation.
From the Microsoft C# specification (section 10.12):
And from the ECMA CLI specification (section 8.9.5):
(Note that C# classes with a static constructor will not have
beforefieldinitsemantics. C# classes without a static constructor will havebeforefieldinitsemantics.)