private async Task <Document> CleanupUsingDirectives(Document document) { var root = await document.GetSyntaxRootAsync() as CompilationUnitSyntax; var usingDirectives = UsingDirectiveHelpers.CleanupUsingDirectives(root.Usings); var newRoot = root.WithUsings(new SyntaxList <UsingDirectiveSyntax>(usingDirectives)); return(document.WithSyntaxRoot(newRoot)); }
private async Task <Document> CleanupUsingDirectives( Document document, NamespaceDeclarationSyntax namespaceDeclaration) { var usingDirectives = UsingDirectiveHelpers.CleanupUsingDirectives(namespaceDeclaration.Usings); var usings = new SyntaxList <UsingDirectiveSyntax>(usingDirectives); var newNamespaceDeclaration = namespaceDeclaration.WithUsings(usings); var root = await document.GetSyntaxRootAsync(); var newRoot = root.ReplaceNode(namespaceDeclaration, newNamespaceDeclaration); return(document.WithSyntaxRoot(newRoot)); }