/// <summary> /// Creates and adds the state property, that will be of the extracted state class type, /// to the source role class. /// </summary> private void AddStateProperty() { TypeReference targetType = TargetType; if (TargetType.HasGenericParameters) { targetType = new GenericInstanceType(TargetType).CopyGenericParametersAsArgumentsFrom(TargetType); } _stateProperty = new PropertyDefinition( DetermineStatePropertyName(), PropertyAttributes.None, targetType); _stateProperty.GetMethod = new MethodDefinition( "get_" + _stateProperty.Name, MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.NewSlot | MethodAttributes.Abstract | MethodAttributes.Virtual | MethodAttributes.SpecialName, targetType) { SemanticsAttributes = MethodSemanticsAttributes.Getter, }; // this property should not conflict with any other member from other types, so mark it as hidden _stateProperty.MarkAsHidden(SourceType.Module); // TODO: only the getter should be marked? _stateProperty.GetMethod.MarkAsHidden(SourceType.Module); SourceType.Properties.Add(_stateProperty); SourceType.Methods.Add(_stateProperty.GetMethod); }