Search code examples
c#roslynfully-qualified-naming

Roslyn - find declarations with fully qualified name


I am using the SymbolFinder.FindDeclarationsAsync() method to find a symbol declared in a project. But the method does not match for fully qualified names.

var symbols = SymbolFinder.FindDeclarationsAsync(projects, "String", true).Result;

The above code returns multiple declarations for String like System.String, System.Data.String, System.Reflection.String, etc

Is there any way to specify "System.String" and get only the ISymbol object for the specified fully qualified name?


Solution

  • It sounds like you are looking for Compilation.GetTypeByMetadataName().