Skip to content

Access SyntaxTree from another project in solution inside a SourceGenerator #50874

Answered by jasonmalinowski
rafalkwol asked this question in Q&A
Discussion options

You must be logged in to vote

Another way that would be acceptable would be to add reference to "SourceGenerator" project in the "Repository" project instead of "Model" project, but then how do I access the the SyntaxTree of "Model" project in the source generator class.

So this is probably the right approach, but yes the source generator running against the Repository project can't see the syntax trees of the Model project because it's already been built and compiled. What it can see though is symbols: if the Repository project has a reference to the Model project the types in the Model project will be visible through the symbol APIs. You could then look at classes/methods that way, as long as you don't need to loo…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@rafalkwol
Comment options

@jasonmalinowski
Comment options

@rafalkwol
Comment options

@onetsmr
Comment options

Answer selected by rafalkwol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants