static void PatchStaticConstructor (TypeDefinition type, HashSet<FieldDefinition> selectors) { var cctor = type.GetTypeConstructor (); if (cctor == null || !cctor.HasBody) return; var instructions = cctor.Body.Instructions; for (int i = 0; i < instructions.Count; i++) { var instruction = instructions [i]; if (!IsCreateSelector (instruction, selectors)) continue; instructions.RemoveAt (i--); instructions.RemoveAt (i--); instructions.RemoveAt (i--); } }
MethodDefinition GetTypeConstructor (TypeDefinition type) { return type.GetTypeConstructor () ?? CreateTypeConstructor (type); }