-
Notifications
You must be signed in to change notification settings - Fork 3
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
Migrate to IIncrementalSourceGenerator #57
base: stable
Are you sure you want to change the base?
Migrate to IIncrementalSourceGenerator #57
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it took me so long to take a look at this. I appreciate your patience.
Regarding your open points:
Add more
Diagnostic
s toCreateSyntaxProvider.transform
instead 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
RenderInfos
from statelessIIncrementalGenerator
when 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 <[email protected]>
Co-authored-by: Miro Knejp <[email protected]>
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 <[email protected]>
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
IIncrementalSourceGenerator
Synopsis
.NET source generation using the
ISourceGenerator
interface is officially deprecated 12.This PR aims to migrate dotvariant to the
IIncrementalSourceGenerator
ecosystem.Subject
Migration of the implementation and test environment.
SourceGenerator
implementationCompilation
into cache, everDiagnostic
s toCreateSyntaxProvider.transform
instead ofreturn default
.dotVariant.Generator.Test
dotVariant.Test-net45
dotVariant.Test-net5.0
RenderInfos
from statelessIIncrementalGenerator
when 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 ↩