I am trying to list all namespaces declared in an assembly. Doing something like this is very inconvenient:
foreach (var syntaxTree in context.Compilation.SyntaxTrees) { foreach (var ns in syntaxTree.GetRoot(context.CancellationToken).DescendantNodes().OfType<NamespaceDeclarationSyntax>()) { ... } }
What is a good way to do this? A walk through the tree will be a bit nicer, but ask earlier, because I have a feeling that this is already somewhere in the API symbol.
source share