-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Revert System.Text.Json source generator changes from PR #124077 #124186
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
base: main
Are you sure you want to change the base?
Conversation
Restore the original pattern where KnownTypeSymbols is created via CompilationProvider to maintain 1-1 correspondence between Compilation and KnownTypeSymbols instances, avoiding performance regression. Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
|
Tagging subscribers to this area: @dotnet/area-system-text-json |
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.
Pull request overview
This PR reverts the System.Text.Json source generator pipeline change from PR #124077 to restore per-compilation caching of KnownTypeSymbols, avoiding redundant symbol resolution and the associated performance regression.
Changes:
- Reintroduced
context.CompilationProvider.Select(...)to create an incrementalKnownTypeSymbolsvalue cached perCompilation. - Restored the
.Combine(knownTypeSymbols).Select(...)pipeline shape so parsing uses the combined(SemanticModel, ContextClass)+ cachedKnownTypeSymbols. - Moved
KnownTypeSymbolsconstruction back out of theForAttributeWithMetadataNametransform.
Description
Reverts System.Text.Json changes from PR #124077 per @eiriktsarpalis feedback. The change caused a performance regression by breaking the 1-1 correspondence between
CompilationandKnownTypeSymbolsinstances, creating fresh instances for everyJsonSerializerContextinstead of caching per compilation.LoggerMessageGenerator changes remain unchanged.
Changes
Restored the original incremental pipeline pattern in
JsonSourceGenerator.Roslyn4.0.cs:Before (PR #124077):
After (this PR):
This ensures
KnownTypeSymbolsis cached per compilation in the incremental pipeline, eliminating redundant type symbol resolution.Testing
Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.