public static IPropertySymbol RemoveAttributeFromParameters( this IPropertySymbol property, INamedTypeSymbol attributeType) { if (attributeType == null) { return(property); } var someParameterHasAttribute = property.Parameters .Any(p => p.GetAttributes().Any(a => a.AttributeClass.Equals(attributeType))); if (!someParameterHasAttribute) { return(property); } return(CodeGenerationSymbolFactory.CreatePropertySymbol( property.ContainingType, property.GetAttributes(), property.DeclaredAccessibility, property.GetSymbolModifiers(), property.Type, property.ExplicitInterfaceImplementations.FirstOrDefault(), property.Name, property.Parameters.Select(p => CodeGenerationSymbolFactory.CreateParameterSymbol( p.GetAttributes().Where(a => !a.AttributeClass.Equals(attributeType)).ToList(), p.RefKind, p.IsParams, p.Type, p.Name, p.IsOptional, p.HasExplicitDefaultValue, p.HasExplicitDefaultValue ? p.ExplicitDefaultValue : null)).ToList(), property.GetMethod, property.SetMethod, property.IsIndexer)); }
public static IPropertySymbol CreatePropertySymbol( IPropertySymbol property, IList <AttributeData> attributes = null, Accessibility?accessibility = null, DeclarationModifiers?modifiers = null, IPropertySymbol explicitInterfaceSymbol = null, string name = null, bool?isIndexer = null, IMethodSymbol getMethod = null, IMethodSymbol setMethod = null) { return(CodeGenerationSymbolFactory.CreatePropertySymbol( attributes, accessibility ?? property.DeclaredAccessibility, modifiers ?? property.GetSymbolModifiers(), property.Type, explicitInterfaceSymbol, name ?? property.Name, property.Parameters, getMethod, setMethod, isIndexer ?? property.IsIndexer)); }
public static IPropertySymbol RenameParameters(this IPropertySymbol property, IList <string> parameterNames) { var parameterList = property.Parameters; if (parameterList.Select(p => p.Name).SequenceEqual(parameterNames)) { return(property); } var parameters = parameterList.RenameParameters(parameterNames); return(CodeGenerationSymbolFactory.CreatePropertySymbol( property.ContainingType, property.GetAttributes(), property.DeclaredAccessibility, property.GetSymbolModifiers(), property.Type, property.ExplicitInterfaceImplementations.FirstOrDefault(), property.Name, parameters, property.GetMethod, property.SetMethod, property.IsIndexer)); }