Skip to content

Feature/optimize resolver#182

Merged
PhenX merged 3 commits intomasterfrom
feature/optimize-resolver
Mar 14, 2026
Merged

Feature/optimize resolver#182
PhenX merged 3 commits intomasterfrom
feature/optimize-resolver

Conversation

@PhenX
Copy link
Collaborator

@PhenX PhenX commented Mar 14, 2026

Benchmark :

Before :
image

After :
image

Registry resolution : 50 to 75 times faster, and no allocations anymore
Reflection resolution : 4 to 5 times faster, 4 to 5 times less allocations

Copy link
Contributor

Copilot AI left a 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 optimizes projection expression resolution by reducing repeated reflection and allocation overhead in both the runtime resolver and the shared class-name generation utilities.

Changes:

  • Add caching and allocation-reduction improvements to ProjectionExpressionResolver (expression cache, type-name cache, reflection factory caching, non-LINQ parameter matching).
  • Optimize generated class-name construction in ProjectionExpressionClassNameGenerator (single-pass namespace/type sanitization).
  • Adjust resolver service contract and related tests/utilities (IProjectionExpressionResolver signature change; GetNestedTypePath returns an array).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/EntityFrameworkCore.Projectables.Tests/Services/ProjectableExpressionReplacerTests.cs Updates resolver stub and lambdas to match the updated resolver interface.
tests/EntityFrameworkCore.Projectables.Tests/Extensions/TypeExtensionTests.cs Updates assertions to use array Length after GetNestedTypePath return type change.
src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionResolver.cs Adds multiple caches and removes LINQ allocations in hot paths for expression resolution.
src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionClassNameGenerator.cs Avoids intermediate string allocations when generating/sanitizing generated type names (shared with generator).
src/EntityFrameworkCore.Projectables/Services/ProjectableExpressionReplacer.cs Passes the already-fetched ProjectableAttribute into the resolver.
src/EntityFrameworkCore.Projectables/Services/IProjectionExpressionResolver.cs Updates resolver interface method signature (optional attribute parameter).
src/EntityFrameworkCore.Projectables/Extensions/TypeExtensions.cs Changes GetNestedTypePath implementation and return type to a pre-sized array.

@PhenX PhenX merged commit d4a6c53 into master Mar 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants