'How to get all C# types or namespaces that Roslyn couldn't find?
I'm using Roslyn to parse a C# project. I have a Microsoft.CodeAnalysis.Compilation object that represents this project. However, this project might not have been compiled successfully; there may be several reasons for this, but I'm specifically interested in any references to a type or a namespace that couldn't be resolved. How can I use my Compilation object to retrieve all unknown namespaces or types as IErrorTypeSymbols?
Solution 1:[1]
you can use semanticModel.GetSymbolInfo(identifierNameSyntax) which returns a SymbolInfo. SymbolInfo.Symbol is an ISymbol, so you can use ISymbol.ContainingNamespace to get the namespace an identifier belongs to.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jeff cassar |
