orleans icon indicating copy to clipboard operation
orleans copied to clipboard

Use Incremental Generators for source-generation

Open Meir017 opened this issue 11 months ago • 4 comments

The source-generator at https://github.com/dotnet/orleans/blob/main/src/Orleans.CodeGenerator/OrleansSourceGenerator.cs is using the deprecated https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.md.

We should be using https://github.com/dotnet/roslyn/blob/main/docs/features/incremental-generators.md

plan:

  • [x] add test project & CI for the existing source-generator - #9459
  • [ ] add code coverage for existing source-generator
  • [ ] split the source generator into multiple small source-generator
  • [ ] migrate each small source generator to use incremental generators

Meir017 avatar Dec 19 '24 19:12 Meir017

We block the source generator from running in VS anyway, so it's not urgent to migrate to the incremental model but I agree that it could be valuable in the long run.

ReubenBond avatar Dec 19 '24 20:12 ReubenBond

Are there tests for the source-generator? do the orleans integration tests cover this as it's required for orleans to work?

Meir017 avatar Apr 22 '25 20:04 Meir017

There aren't any specific tests other than the integration tests, which (hopefully) give good coverage. They test many corner cases like generics, nested types, various other constructs. Some of the tests are (unfortunately) indirect: the existence of a type triggers codegen, and the "test" is that the resulting code doesn't break the build.

It would be ideal if we could chop the source generator up into one or more incremental generators and make it more testable, and let it share code with the analyzers. It would take a lot of work, I believe.

ReubenBond avatar Apr 23 '25 01:04 ReubenBond

@ReubenBond I updated the description of this issue with a suggested plan for getting this done safely

Meir017 avatar Apr 25 '25 08:04 Meir017