0

AIUI, transitive references are an MSBuild rather than a Roslyn feature, and are to do with Package/ProjectReferences rather than assembly references. I believe the compiler just gets a set of assembly references supplied to it and no information about where they came from. As a result, I don't see any way to distinguish between direct and transitive references from within an analyzer or source generator (i.e. given a CodeAnalysis.Compilation object). Compilation.References includes the transitive ones, as does Compilation.ReferencedAssemblyNames.

Does anybody know a way to get at this information? Is it possible to get hold of an MsBuild Project object, from which it could be gleaned?

Tom
  • 1,204
  • 2
  • 10
  • 25

1 Answers1

1

There's no way to get to this information; as you observed MSBuild is doing this, and by the time Roslyn gets the information it's just a flat list. We don't have any way to reach back to the MSBuild instance, for various technical reasons. If you clarify why you are needing this we might be able to give some advice for next steps.

Jason Malinowski
  • 18,148
  • 1
  • 38
  • 55