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

Ship V2 as a source generator instead of a library #67

Open
Blackclaws opened this issue Aug 1, 2024 · 3 comments
Open

Ship V2 as a source generator instead of a library #67

Blackclaws opened this issue Aug 1, 2024 · 3 comments

Comments

@Blackclaws
Copy link

Adding libraries to source generators as dependencies is notoriously hard:

https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md#use-functionality-from-nuget-packages

And it gets worse if multiple generators use the same library but in different versions as roslyn does not currently load them into different domains.

Instead I would suggest shipping V2 as a generator in its own right that simply adds these files post initialization so they are compiled into the source generator directly without people needing to copy things manually.

@MichaelHochriegl
Copy link
Contributor

Nice idea, but AFAIK stacking source gens on top of each other should not be done, as execution order can vary. Or did this change somehow and can now be done safely?

@Blackclaws
Copy link
Author

Stacking source generators is a difficult topic and by default not even supported unless you take a direct dependency on the other source generator and then call it manually as source generators cannot see the output of other source generators.

That is however not relevant here, as I am not proposing packaging this project as an additional source generator to be applied to the final target but instead to use this project as a source generator for a source generator. Meaning the generated source will be compiled into the generator and just be part of it as if you copied the files in.

This is not stacking source generators at all.

@MichaelHochriegl
Copy link
Contributor

Ah, sorry, I must have misunderstood your approach than. I played around with SGs a little more and get your solution now. Thanks for clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants