private Instruction EmitStateClassCreation(TypeReference role, Instruction instructionBeforeCreation, ILProcessor il) { var current = instructionBeforeCreation; var stateClassFieldReference = ResolveStateClassField(role); // don't emit this code if the state field and property was not implemented // TODO: this needs to be checked before, possibly at the conflict resolution stage if (stateClassFieldReference != null) { current = InsertAfter(il, current, il.Create(OpCodes.Ldarg_0)); current = InsertAfter(il, current, il.Create(OpCodes.Newobj, role.ResolveStateClassCtor())); current = InsertAfter(il, current, il.Create(OpCodes.Stfld, stateClassFieldReference)); } return current; }