public CommandInterfaceBuilder WithReferences(IEnumerable <string> references)
 {
     namespaceDeclaration = namespaceDeclaration.AddUsings(
         references.Select(
             x => SyntaxFactory.UsingDirective(SyntaxFactory.ParseName(x))).ToArray()
         );
     return(this);
 }
Beispiel #2
0
        /// <summary>Called when the visitor visits a NamespaceDeclarationSyntax node.</summary>
        public override SyntaxNode VisitNamespaceDeclaration(NamespaceDeclarationSyntax node)
        {
            var u = _namespaces.Select(each => SyntaxFactory.UsingDirective(SyntaxFactory.ParseName($" {each}"))
                .WithLeadingTrivia(_leadingTrivia)
                .WithTrailingTrivia(_trailingTrivia)
            ).ToArray();

            node = node.AddUsings(u);
            node = node.WithUsings(Sort(node.Usings));
            return base.VisitNamespaceDeclaration(node);
        }