private static AttributeListSyntax GetNewAttributeList(AttributeListSyntax attributeList, ITypeSymbol optionalAttribute, SemanticModel semanticModel) { var attributeName = optionalAttribute.ToMinimalDisplayString(semanticModel, attributeList.SpanStart); attributeName = attributeName.Remove(attributeName.IndexOf("Attribute", System.StringComparison.Ordinal)); return attributeList.AddAttributes( SyntaxFactory.Attribute( SyntaxFactory.ParseName(attributeName))) .WithAdditionalAnnotations(Formatter.Annotation); }
private static AttributeListSyntax GetNewAttributeList(AttributeListSyntax attributeList, ITypeSymbol optionalAttribute, SemanticModel semanticModel) { var attributeName = optionalAttribute.ToMinimalDisplayString(semanticModel, attributeList.SpanStart); attributeName = attributeName.Remove(attributeName.IndexOf("Attribute", System.StringComparison.Ordinal)); return(attributeList.AddAttributes( SyntaxFactory.Attribute( SyntaxFactory.ParseName(attributeName))) .WithAdditionalAnnotations(Formatter.Annotation)); }
public static AttributeListSyntax JoinAttributes(IList <AttributeListSyntax> lists) { AttributeListSyntax list = lists[0]; for (int i = 1; i < lists.Count; i++) { list = list.AddAttributes(lists[i].Attributes.ToArray()); } return(list .WithLeadingTrivia(lists[0].GetLeadingTrivia()) .WithTrailingTrivia(lists.Last().GetTrailingTrivia())); }
public static AttributeListSyntax MergeAttributes(AttributeListSyntax[] lists) { AttributeListSyntax list = lists[0]; for (int i = 1; i < lists.Length; i++) { list = list.AddAttributes(lists[i].Attributes.ToArray()); } return(list .WithLeadingTrivia(lists[0].GetLeadingTrivia()) .WithTrailingTrivia(lists.Last().GetTrailingTrivia()) .WithFormatterAnnotation()); }
public static AttributeListSyntax MergeAttributes(AttributeListSyntax[] attributeLists) { if (attributeLists == null) { throw new ArgumentNullException(nameof(attributeLists)); } AttributeListSyntax attributeList = attributeLists[0]; for (int i = 1; i < attributeLists.Length; i++) { attributeList = attributeList.AddAttributes(attributeLists[i].Attributes.ToArray()); } return(attributeList .WithLeadingTrivia(attributeLists.First().GetLeadingTrivia()) .WithTrailingTrivia(attributeLists.Last().GetTrailingTrivia())); }
public static AttributeListSyntax MergeAttributes(AttributeListSyntax[] lists) { if (lists == null) { throw new ArgumentNullException(nameof(lists)); } AttributeListSyntax list = lists[0]; for (int i = 1; i < lists.Length; i++) { list = list.AddAttributes(lists[i].Attributes.ToArray()); } return(list .WithLeadingTrivia(lists[0].GetLeadingTrivia()) .WithTrailingTrivia(lists.Last().GetTrailingTrivia()) .WithFormatterAnnotation()); }