-
Notifications
You must be signed in to change notification settings - Fork 256
Refactor method/member translators to stop using reflection lookup #3721
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
Conversation
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
Refactors several EFCore.PG method/member translators to avoid reflection-based MethodInfo lookups, switching to name/declaring-type pattern matching to improve trimming/AOT compatibility (per linked EF Core issue).
Changes:
- Removed many cached
MethodInfofields and reflection lookups in translators/filters. - Replaced
MethodInfoequality checks withDeclaringType/Name/argument-shape checks andswitchexpressions. - Converted several translators to primary constructors / field initializers.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/EFCore.PG/Query/Internal/NpgsqlEvaluatableExpressionFilter.cs | Replaces MethodInfo equality checks for tsquery/tsvector Parse with name/declaring-type checks. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlTrigramsMethodTranslator.cs | Replaces reflection-built dictionaries with method.Name switch-based dispatch. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs | Removes many cached MethodInfos and converts translations to method.Name pattern matching/switches. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRowValueTranslator.cs | Replaces comparison MethodInfo map with method.Name switch for EF.Functions row comparisons. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRangeTranslator.cs | Replaces Enumerable.Any() reflection lookup with declaring-type/name/argument pattern checks. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRandomTranslator.cs | Replaces MethodInfo equality check for DbFunctionsExtensions.Random with declaring-type/name check. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlNetworkTranslator.cs | Replaces Parse method MethodInfo checks with declaring-type/name/argument checks and refactors mapping selection. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlMiscAggregateMethodTranslator.cs | Replaces cached MethodInfo checks for string aggregation with declaring-type/name switch. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlMathTranslator.cs | Replaces large MethodInfo map with DeclaringType filter + method.Name switch and local helpers. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlLikeTranslator.cs | Replaces MethodInfo equality checks with declaring-type/name checks and adds argument-count handling for escape overloads. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlJsonPocoTranslator.cs | Replaces reflection-based Enumerable.Any lookup with declaring-type/name/argument pattern checks. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlJsonDomTranslator.cs | Replaces cached MemberInfo/MethodInfo checks with member/method name checks for JSON DOM traversal. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlFuzzyStringMatchMethodTranslator.cs | Replaces reflection-built map with method.Name switch and declaring-type guard. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlFullTextSearchMethodTranslator.cs | Replaces tsquery/tsvector Parse MethodInfo checks with declaring-type/name checks. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlDateTimeMethodTranslator.cs | Removes large reflection-based map and replaces parts with name/declaring-type checks/switches. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlConvertTranslator.cs | Replaces reflection-built supported methods list with declaring-type/name/type checks. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlBigIntegerMemberTranslator.cs | Replaces cached MemberInfo checks with member-name switch guarded by declaring type. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlArrayMethodTranslator.cs | Replaces reflection-based method identification (ElementAt/SequenceEqual/etc.) with name/declaring-type/argument patterns. |
| src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeMethodCallTranslatorPlugin.cs | Removes many cached MethodInfos; uses name/declaring-type switches for NodaTime method translation. |
| src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeMemberTranslatorPlugin.cs | Converts plugin property init; replaces cached members with member-name checks; refactors translator construction. |
| src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeEvaluatableExpressionFilterPlugin.cs | Replaces cached MethodInfo/MemberInfo checks with declaring-type/name checks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlDateTimeMethodTranslator.cs
Show resolved
Hide resolved
src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlNetworkTranslator.cs
Outdated
Show resolved
Hide resolved
src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs
Show resolved
Hide resolved
src/EFCore.PG/Query/Internal/NpgsqlEvaluatableExpressionFilter.cs
Outdated
Show resolved
Hide resolved
src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs
Outdated
Show resolved
Hide resolved
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
Copilot reviewed 21 out of 21 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
See dotnet/efcore#27113