AutoLazy.Fody.TypeExtensions.GetOrCreateStaticConstructor C# (CSharp) Method

GetOrCreateStaticConstructor() public static method

public static GetOrCreateStaticConstructor ( this type ) : Mono.Cecil.MethodDefinition
type this
return Mono.Cecil.MethodDefinition
        public static MethodDefinition GetOrCreateStaticConstructor(this TypeDefinition type)
        {
            var cctor = type.GetStaticConstructor();
            if (cctor != null) return cctor;
            cctor = new MethodDefinition(".cctor", _staticConstructorAttributes, type.Module.Import(typeof(void)));
            type.Methods.Add(cctor);
            var il = cctor.Body.GetILProcessor();
            il.Emit(OpCodes.Ret);
            return cctor;
        }