1

I am currently writing a source generator. This source generator should not only take into account the types and syntax trees in the project it's added to, but also the projets the target project references:

  • TargetProject
    • SourceGenerator
    • RefProjectA
    • RefProjectB

How can I get the semantic model/source code of RefProjectA when the source generator is applied to TargetProject?

Eike S
  • 300
  • 1
  • 11
  • Can you please clarify what your starting point is? Is it a fully qualified class name in `RefProjectA` and you want to get its `ITypeSymbol`? i.e. `SemanticModel.Compilation.GetTypeByMetadataName`? – Kirk Woll Jun 03 '22 at 12:19
  • @KirkWoll I want to analyse AttributeData and other info from the semantic model of referenced projects. The Generator is added to the target project and that targetproject has projectreferences to other projects in the same solution. I want to load the semantic model of these projects – Eike S Jun 03 '22 at 13:17
  • Right, but what does "the semantic model of the referenced projects" specifically refer to? A project doesn't really have a semantic model, but a type does. So you can find a type using the method I mentioned above. Is that not what you are seeking? If not, can you give a more concrete example? – Kirk Woll Jun 03 '22 at 13:47

0 Answers0