Reputation: 913
I am writing code analysis which should check if our libraries are used properly. For that I need to know which assemblies are referenced by project (=analyzed document's parent project). It is possible in CodeRefactoringProviders as its context contains Document property. From document I can get to the Project and its References.
But I do not know how to get the information from CodeAnalysis contexts (SyntaxNodeAnalysisContext, ...) Is is possible?
Upvotes: 1
Views: 254
Reputation: 19021
If you register for CompilationStarted, you can get a Compilation object, and from that compilation there's a References property. You can cast those to PortableExecutableReference
if you need file paths, or you can get symbols if you need to assert other things about them.
Upvotes: 3