private void CreateExplicitInterfaceImplementations(TypeDefinitionMember member) { List <ITypeDefinitionMember> interfaceMembers = Util.FindRelatedInterfaceMembers(member); foreach (ITypeDefinitionMember interfaceMember in interfaceMembers) { IMethodDefinition methodDef = interfaceMember.ResolvedTypeDefinitionMember as IMethodDefinition; if (methodDef != null) { List <IMethodImplementation> methodImpls = null; methodImpls = GetExplicitImplementationOverrides(member, methodImpls); if (methodImpls != null) { // Make sure implementedmethod is in the closure TrimType trimType = (TrimType)_currentTrimAssembly.GetTypeElement(Util.GetTypeName(Util.ContainingTypeDefinition(interfaceMember))); if (trimType != null) { TrimMember trimMember = trimType.GetMemberElementFromMember(interfaceMember); if (trimMember != null) { MethodImplementation methodImpl = new MethodImplementation(); methodImpl.ImplementedMethod = interfaceMember.ResolvedTypeDefinitionMember as IMethodReference; methodImpl.ImplementingMethod = member as IMethodReference; methodImpl.ContainingType = member.ContainingTypeDefinition; methodImpls.Add(Rewrite(methodImpl)); } } } } } }
private void MutateMember(TypeDefinitionMember member, Element element) { // Set transparency attributes. if (_applyAnnotations) { SecurityTransparencyStatus currentStatus = GetMarkedSecurityAnnotation(member.Attributes, member.ContainingTypeDefinition); if (element.SecurityTransparencyStatus != SecurityTransparencyStatus.Undefined && currentStatus != element.SecurityTransparencyStatus) { RemoveSecurityTransparencyAttributes(member.Attributes, member.ContainingTypeDefinition); AddSecurityTransparencyAttribute(member.Attributes, element.SecurityTransparencyStatus, member.ContainingTypeDefinition); } } // Add FriendAccessAllowed attribute. if (!(member is PropertyDefinition)) // FAA isn't needed on properties; it's only needed on getters and setters { List <ICustomAttribute> attributes = member.Attributes; AddFaaAttributeIfNeeded(element, attributes, member.ContainingTypeDefinition); } // Make internal if needed. if (_changeVisibility && element.ShouldMakeInternal && !Util.IsInternal(member.ResolvedTypeDefinitionMember.Visibility)) { // Make the member internal MakeInternal(member); // Interface method implementations don't need Explicit Interface Method Implementations (EIMI's) if the implementing // method is public and has the same signature as the interface method. Since we're making the method internal, // we need to add the EIMI's. CreateExplicitInterfaceImplementations(member); } }
private List <IMethodImplementation> GetExplicitImplementationOverrides(TypeDefinitionMember member, List <IMethodImplementation> methodImpls) { INamespaceTypeDefinition namespaceTypeDef = member.ContainingTypeDefinition as INamespaceTypeDefinition; INestedTypeDefinition nestedTypeDef = member.ContainingTypeDefinition as INestedTypeDefinition; if (namespaceTypeDef != null) { methodImpls = ((NamespaceTypeDefinition)namespaceTypeDef).ExplicitImplementationOverrides; } else if (nestedTypeDef != null) { methodImpls = ((NamespaceTypeDefinition)namespaceTypeDef).ExplicitImplementationOverrides; } else { throw new InvalidOperationException("ExplicitImplementationOverrides can only be accessed on a NamespaceTypeDefinition or a NestedTypeDefinition object"); } return(methodImpls); }
private List<IMethodImplementation> GetExplicitImplementationOverrides(TypeDefinitionMember member, List<IMethodImplementation> methodImpls) { INamespaceTypeDefinition namespaceTypeDef = member.ContainingTypeDefinition as INamespaceTypeDefinition; INestedTypeDefinition nestedTypeDef = member.ContainingTypeDefinition as INestedTypeDefinition; if (namespaceTypeDef != null) { methodImpls = ((NamespaceTypeDefinition)namespaceTypeDef).ExplicitImplementationOverrides; } else if (nestedTypeDef != null) { methodImpls = ((NamespaceTypeDefinition)namespaceTypeDef).ExplicitImplementationOverrides; } else { throw new InvalidOperationException("ExplicitImplementationOverrides can only be accessed on a NamespaceTypeDefinition or a NestedTypeDefinition object"); } return methodImpls; }
private void MakeInternal(TypeDefinitionMember member) { member.Visibility = GetInternalVisibility(member.Visibility); }
private void CreateExplicitInterfaceImplementations(TypeDefinitionMember member) { List<ITypeDefinitionMember> interfaceMembers = Util.FindRelatedInterfaceMembers(member); foreach (ITypeDefinitionMember interfaceMember in interfaceMembers) { IMethodDefinition methodDef = interfaceMember.ResolvedTypeDefinitionMember as IMethodDefinition; if (methodDef != null) { List<IMethodImplementation> methodImpls = null; methodImpls = GetExplicitImplementationOverrides(member, methodImpls); if (methodImpls != null) { // Make sure implementedmethod is in the closure TrimType trimType = (TrimType)_currentTrimAssembly.GetTypeElement(Util.GetTypeName(Util.ContainingTypeDefinition(interfaceMember))); if (trimType != null) { TrimMember trimMember = trimType.GetMemberElementFromMember(interfaceMember); if (trimMember != null) { MethodImplementation methodImpl = new MethodImplementation(); methodImpl.ImplementedMethod = interfaceMember.ResolvedTypeDefinitionMember as IMethodReference; methodImpl.ImplementingMethod = member as IMethodReference; methodImpl.ContainingType = member.ContainingTypeDefinition; methodImpls.Add(Rewrite(methodImpl)); } } } } } }
private void MutateMember(TypeDefinitionMember member, Element element) { // Set transparency attributes. if (_applyAnnotations) { SecurityTransparencyStatus currentStatus = GetMarkedSecurityAnnotation(member.Attributes, member.ContainingTypeDefinition); if (element.SecurityTransparencyStatus != SecurityTransparencyStatus.Undefined && currentStatus != element.SecurityTransparencyStatus) { RemoveSecurityTransparencyAttributes(member.Attributes, member.ContainingTypeDefinition); AddSecurityTransparencyAttribute(member.Attributes, element.SecurityTransparencyStatus, member.ContainingTypeDefinition); } } // Add FriendAccessAllowed attribute. if (!(member is PropertyDefinition)) // FAA isn't needed on properties; it's only needed on getters and setters { List<ICustomAttribute> attributes = member.Attributes; AddFaaAttributeIfNeeded(element, attributes, member.ContainingTypeDefinition); } // Make internal if needed. if (_changeVisibility && element.ShouldMakeInternal && !Util.IsInternal(member.ResolvedTypeDefinitionMember.Visibility)) { // Make the member internal MakeInternal(member); // Interface method implementations don't need Explicit Interface Method Implementations (EIMI's) if the implementing // method is public and has the same signature as the interface method. Since we're making the method internal, // we need to add the EIMI's. CreateExplicitInterfaceImplementations(member); } }