Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 271
CasKaDev Avatar asked Sep 16 '25 21:09

CasKaDev


1 Answers

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

like image 152
Kevin Pilch Avatar answered Sep 19 '25 09:09

Kevin Pilch