Roslyn: get the symbol for a type defined in a third-party library

喜欢而已 提交于 2019-12-04 11:37:04
JoshVarty

If you can get access to a Compilation you can call Compilation.GetTypeByMetadataName() and pass in the fully qualified metadata name for the symbol.

Be careful of nested classes and generics, their metadata names are different than they're normal fully qualified names. For more see: C# : having a "+" in the class name?

Once you have the symbol you can find all usages via SymbolFinder.FindAllReferences()

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!