Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VDG] Combined Source Generator #11401

Merged
merged 8 commits into from
Sep 4, 2023

Conversation

ichthus1604
Copy link
Collaborator

@ichthus1604 ichthus1604 commented Aug 30, 2023

Problem Statement

TL;DR: Source Generators cannot depend on the output of other source generators

Syntax Trees added by source generators are not added to the Compilation passed to other source generators, and the execution order of several generators in the same assembly is non deterministic.

This is a problem when generator A needs to do semantic analysis of types created by generator B. If no semantic analysis is required, this problem does not surface.

Solution

This PR introduces CombinedGenerator, which may contain GeneratorSteps, and accumulatively updates the Compilation object introducing the syntax trees added by each step, in order for the next step to receive the updated Compilation including all previously added syntax trees.

A GeneratorStep might also depend on Code Analysis artifacts other than source generated Syntax Trees, created by a previous step in the same execution, therefore this PR introduces a nice API to do just that.

Additionally, the generation of static files (such as generated attributes, etc) which depend neither on syntactic nor semantic analysis is encapsulated in a nice API as well.

Why?

FluentNavigationGenerator actually depends on the output of UiContextConstructorGenerator. In master, these are meshed together in the same class (the latter), and there is an ad-hoc trick to workaround the problem stated above with the Compilation object.

This PR formalizes that ad-hoc trick into a proper, nice to use API.

Both UiContextConstructorGenerator and FluentNavigationGenerator have been refactored to this new API and are working as expected in this PR.

But seriously, why?

Because I needed this in order to make [AutoInterface] work.

Copy link
Collaborator

@soosr soosr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cACK, although I can't review the PR efficiently.

@soosr soosr merged commit ae8d71d into WalletWasabi:master Sep 4, 2023
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants