public static void ParseMMILAccessCtorHead( MonoModder self, MethodBody body, MethodReference callCtor, ref int instri, out TypeReference type_, out IMetadataTokenProvider member_ ) { TypeReference type = null; IMetadataTokenProvider member = null; if (callCtor.DeclaringType.IsGenericInstance) { type = self.Relink(((GenericInstanceType)callCtor.DeclaringType).GenericArguments[0], body.Method); } if (callCtor.Parameters.Count >= 2 && callCtor.Parameters[callCtor.Parameters.Count - 2].Name == "type") { type = self.FindTypeDeep((string)body.Instructions[instri - 2].Operand); body.Instructions.RemoveAt(instri - 2); instri--; } else if (callCtor.Parameters.Count == 1 && callCtor.Parameters[0].Name == "type") { type = self.FindTypeDeep((string)body.Instructions[instri - 1].Operand); body.Instructions.RemoveAt(instri - 1); instri--; } TypeDefinition typeDef = type.Resolve(); if (callCtor.Parameters.Count >= 1 && callCtor.Parameters[callCtor.Parameters.Count - 1].Name == "name") { string memberName = (string)body.Instructions[instri - 1].Operand; body.Instructions.RemoveAt(instri - 1); instri--; if (memberName.StartsWith("field:")) { member = typeDef.FindField(memberName.Substring(6).Trim()); } else if (memberName.StartsWith("method:")) { member = typeDef.FindMethod(memberName.Substring(7).Trim()); } else { member = typeDef.FindField(memberName) ?? (IMetadataTokenProvider)typeDef.FindMethod(memberName); } member.SetPublic(true); } // Remove the newobj constructor call body.Instructions.RemoveAt(instri); type_ = type; member_ = member; }