JsonApiDotNetCore icon indicating copy to clipboard operation
JsonApiDotNetCore copied to clipboard

Source generator tweaks

Open bkoelman opened this issue 3 years ago • 1 comments

This PR adds the following header comment to auto-generated controller classes:

// <auto-generated />

The comment instructs other analyzers, such as StyleCop, to skip analyzing such files, so you won't get suggestions or warnings in them.

I've also updated the project to C# 10, so we can use static lambdas to avoid accidental closure allocations.

On my 6-year-old home computer, building the integration tests project takes ~40 seconds. I suspect this is caused by our controller source generator (the project contains a large number of resources). So I explored switching to incremental source generators, until I realized they can only potentially improve IDE IntelliSense performance and don't improve the speed of command-line builds. Furthermore, there are lots of open bugs and some users report a massive increase in memory usage. Therefore I aborted this effort.

I also tried to reduce the number of Compilation lookups, replacing them with hardcoded qualified type names. But this did not result in measurable performance improvements. These lookups are probably cached inside roslyn.

QUALITY CHECKLIST

  • [x] Changes implemented in code
  • [x] Complies with our contributing guidelines
  • [ ] N/A: Adapted tests
  • [ ] N/A: Documentation updated

bkoelman avatar Aug 09 '22 23:08 bkoelman

Codecov Report

Merging #1178 (549586b) into master (0185311) will increase coverage by 0.00%. The diff coverage is 97.86%.

@@           Coverage Diff           @@
##           master    #1178   +/-   ##
=======================================
  Coverage   92.58%   92.58%           
=======================================
  Files         241      241           
  Lines        7700     7703    +3     
=======================================
+ Hits         7129     7132    +3     
  Misses        571      571           
Impacted Files Coverage Δ
...ApiDotNetCore.SourceGenerators/SourceCodeWriter.cs 97.56% <97.50%> (+0.08%) :arrow_up:
...Core.SourceGenerators/ControllerSourceGenerator.cs 98.43% <98.43%> (-0.03%) :arrow_down:
...ourceGenerators/TypeWithAttributeSyntaxReceiver.cs 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us.

codecov[bot] avatar Aug 10 '22 00:08 codecov[bot]