Esempio n. 1
0
        private IEnumerable <SyntaxNode> BuildSyntax(IAttribute item)
        {
            var itemAsT    = item as IAttribute;
            var nameSyntax = SyntaxFactory.ParseName(itemAsT.Name);

            var node = SyntaxFactory.Attribute(nameSyntax);

            node = BuildSyntaxHelpers.AttachWhitespace(node, item.Whitespace2Set, WhitespaceLookup);
            var attributeArgList = itemAsT.AttributeValues
                                   .SelectMany(x => RDom.CSharp.GetSyntaxGroup(x))
                                   .OfType <AttributeArgumentSyntax>()
                                   .ToList();

            if (attributeArgList.Any())
            {
                var argList = SyntaxFactory.AttributeArgumentList(
                    SyntaxFactory.SeparatedList(attributeArgList));
                argList = BuildSyntaxHelpers.AttachWhitespace(argList, item.Whitespace2Set, WhitespaceLookup);
                node    = node.WithArgumentList(argList);
            }

            var nodeList = SyntaxFactory.AttributeList(
                SyntaxFactory.SeparatedList(
                    new AttributeSyntax[] {
                (AttributeSyntax)BuildSyntaxHelpers.PrepareForBuildItemSyntaxOutput(node, item, OutputContext)
            }));

            nodeList = BuildSyntaxHelpers.AttachWhitespace(nodeList, item.Whitespace2Set, WhitespaceLookup);

            return(nodeList.PrepareForBuildSyntaxOutput(item, OutputContext));
        }