public static void AddAutoPropertySetterInstruction(this InstructionComposer composer, FieldDefinition field) { composer.LoadArg_0() .LoadArg_1() .Store(field) .Return(); }
private static MethodDefinition CreateAutoPropertyGetter(this TypeDefinition typeDefinition, ModuleDefinition moduleDefinition, string propertyName, FieldDefinition field, TypeReference retTypeReference, bool vir = false) { var attributes = MethodAttributes.FamANDAssem | MethodAttributes.Family | MethodAttributes.HideBySig | MethodAttributes.SpecialName; var composer = new InstructionComposer(moduleDefinition); composer.AddAutoPropertyGetterInstruction(field); var getter = typeDefinition.CreateGetter(moduleDefinition, propertyName, retTypeReference, composer.Instructions, attributes, vir); getter.CustomAttributes.Add(new CustomAttribute( moduleDefinition.ImportReference(typeof(CompilerGeneratedAttribute).GetConstructor(Type.EmptyTypes)))); return(getter); }