Migrate to IIncrementalSourceGenerator#57
Migrate to IIncrementalSourceGenerator#57ProphetLamb wants to merge 39 commits intomknejp:stablefrom
Conversation
to generate the name hint
Note: IIncrementalSourceGenerators should not keep a state for performance reasons.
nullable annotations are not allowed
|
Thank you very much for tackling this. It might take a few days before I am able to do a review. |
|
Alighty, thanks:) |
|
@mknejp Is there any chance you could review the PR? Best regards |
mknejp
left a comment
There was a problem hiding this comment.
Sorry it took me so long to take a look at this. I appreciate your patience.
Regarding your open points:
Add more
Diagnostics toCreateSyntaxProvider.transforminstead ofreturn default.
What kind of diagnostics are you referring to? Do you mean the ones in CreateSyntaxProvider? Would these errors not indicate that either the predicate is wrong, or that there's a bug in Roslyn?
Resolve hack used to obtain
RenderInfosfrom statelessIIncrementalGeneratorwhen debugging.
I think the only "clean" way to resolve this (technically the previous solution wasn't "clean" either) would be have a static function that builds the transformation graph and then trigger it manually in the tests. However I have no idea how feasible this is so I'm willing to accept the current "hack". However I would sleep better if it was a thread-safe list as I have no idea how the generator transformations are threaded.
I also think it would be nicer to move some of the larger lambda expressions in Initialize to dedicated named functions to make the structure of the transformers stand out more. Do you agree?
Lastly, we need to find a solution for the copyright headers. You used my name in the new files, which I assume is a consequence of the .editorconfig file, but that is technically wrong. I also don't want to erase your effort. This is definitely a priority.
Co-authored-by: Miro Knejp <miro@knejp.de>
Co-authored-by: Miro Knejp <miro@knejp.de>
Generally I think a fatal error should be produced, instead of no output. For example, the user imports the package into F#.
I think this is best solved this using a static class annotated with debug only using a
Agreed. Done.
Since |
I was thinking of removing all the names from source files (including mine) and just keeping it in the git history. I would create a PR to change the existing files over and you can then rebase yours on top, if that is an acceptabl solution for you. |
|
I personally hate these giant license comments in files that just keep growing and growing. |
Co-authored-by: Miro Knejp <miro@knejp.de>
|
I had to move the project to |
I added a separate test project for isolated tests of internal functionality. |
Agreed. I will manually update files added by this PR once the rebase is incoming. |
I don't think we need a separate test project. The other test projects ensure that the generator can be used externally as
This work is now done. The file headers are adjusted and you can add yourself to the |
Migrate to
IIncrementalSourceGeneratorSynopsis
.NET source generation using the
ISourceGeneratorinterface is officially deprecated 12.This PR aims to migrate dotvariant to the
IIncrementalSourceGeneratorecosystem.Subject
Migration of the implementation and test environment.
SourceGeneratorimplementationCompilationinto cache, everDiagnostics toCreateSyntaxProvider.transforminstead ofreturn default.dotVariant.Generator.TestdotVariant.Test-net45dotVariant.Test-net5.0RenderInfosfrom statelessIIncrementalGeneratorwhen debugging.Postscriptum
I've been using this lovely package for a while now. So I took some time this beautiful afternoon to do a good chunk of the dirty work required to keep this project up to date.
@mknejp Any and all help, in the form of reviews, or with the remaining open points is much appreciated.
Footnotes
https://github.com/dotnet/roslyn-analyzers/pull/6478 ↩
https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md ↩