-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Refactor method/member translators to stop using reflection lookup #37656
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
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 multiple provider-specific method/member translators to avoid eager MethodInfo/MemberInfo reflection lookups (improving trimming compatibility and reducing startup reflection overhead), switching to name/declaring-type matching and argument-shape validation.
Changes:
- Replace static reflection-based
MethodInfo/MemberInfocaches withDeclaringType/Namechecks (often with list-pattern argument validation). - Convert many translators to primary-constructor style and remove backing
_sqlExpressionFactoryfields where possible. - Simplify/reshape some translation helpers (e.g., math/string translation dispatch via
switch).
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteSubstrMethodTranslator.cs | Stop caching MethodInfo; match Substr by declaring type/name and argument shape. |
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteStringMethodTranslator.cs | Replace many cached MethodInfo checks with switch on method name and argument patterns. |
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteStringLengthTranslator.cs | Member translation switches from reflection lookup to name/declaring-type checks. |
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteStringAggregateMethodTranslator.cs | Stop caching MethodInfo; select separator based on method name/arguments. |
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteRegexMethodTranslator.cs | Match Regex.IsMatch without cached MethodInfo. |
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteRandomTranslator.cs | Match DbFunctionsExtensions.Random without cached MethodInfo. |
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteQueryableAggregateMethodTranslator.cs | Primary-constructor refactor; use injected factory directly. |
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteObjectToStringTranslator.cs | Remove HashSet<Type> in favor of explicit supported-type checks. |
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteMathTranslator.cs | Replace static MethodInfo dictionary with method-name/type-based dispatch and helpers. |
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteHexMethodTranslator.cs | Stop caching MethodInfo; match Hex/Unhex by declaring type/name and args. |
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteGlobMethodTranslator.cs | Stop caching MethodInfo; match Glob by declaring type/name and args. |
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteDateTimeMethodTranslator.cs | Replace MethodInfo mapping dictionaries with method-name-based dispatch and shared modifier helper. |
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteDateOnlyMethodTranslator.cs | Minor pattern-match simplification for DateOnly.FromDateTime. |
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteCharMethodTranslator.cs | Replace supported-method dictionary with method-name-based dispatch. |
| src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteByteArrayMethodTranslator.cs | Replace EnumerableMethods.Contains MethodInfo match with declaring-type/name/args checks. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerTimeOnlyMethodTranslator.cs | Stop caching MethodInfo; match TimeOnly methods via names/argument patterns. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerStringMethodTranslator.cs | Replace many cached MethodInfo checks with method-name/arg-shape dispatch; extract helpers. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerStringAggregateMethodTranslator.cs | Stop caching MethodInfo; select separator based on method name/arguments. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerNewGuidTranslator.cs | Match Guid.NewGuid without cached MethodInfo. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerMathTranslator.cs | Replace static mapping dictionaries with method-name/type-based dispatch and local helpers. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerIsNumericFunctionTranslator.cs | Stop caching MethodInfo; match IsNumeric by declaring type/name. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerIsDateFunctionTranslator.cs | Stop caching MethodInfo; match IsDate by declaring type/name. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerFullTextSearchFunctionsTranslator.cs | Replace reflection-based mapping with method-name dispatch for FreeText/Contains. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerFromPartsFunctionTranslator.cs | Replace reflection-based function mapping with method-name dispatch. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerDateTimeMethodTranslator.cs | Replace MethodInfo mapping dictionaries with method-name-based dispatch for DATEADD/Unix time conversions. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerDateOnlyMethodTranslator.cs | Replace reflection mappings with method-name-based dispatch and argument-pattern checks. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerDateDiffFunctionsTranslator.cs | Replace large MethodInfo mapping dictionary with method-name-based dispatch. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerDataLengthFunctionTranslator.cs | Remove MethodInfo set and use declaring-type/name checks plus store-type pattern matching. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerConvertTranslator.cs | Remove static reflection initialization; validate Convert.ToX via name + parameter-type checks. |
| src/EFCore.SqlServer/Query/Internal/Translators/SqlServerByteArrayMethodTranslator.cs | Replace EnumerableMethods.* MethodInfo comparisons with declaring-type/name/args checks. |
| src/EFCore.Cosmos/Query/Internal/Translators/CosmosStringMethodTranslator.cs | Remove many cached MethodInfo fields; dispatch via method-name/argument patterns. |
| src/EFCore.Cosmos/Query/Internal/Translators/CosmosRegexTranslator.cs | Match Regex.IsMatch by declaring type/name and argument-count patterns. |
| src/EFCore.Cosmos/Query/Internal/Translators/CosmosRandomTranslator.cs | Match DbFunctionsExtensions.Random by declaring type/name. |
| src/EFCore.Cosmos/Query/Internal/Translators/CosmosMathTranslator.cs | Replace static MethodInfo dictionary with method-name/type-based dispatch. |
| src/EFCore.Cosmos/Query/Internal/Translators/CosmosDateTimeMethodTranslator.cs | Replace reflection-based date-part mapping with method-name dispatch (with declaring-type guard). |
src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteStringMethodTranslator.cs
Show resolved
Hide resolved
src/EFCore.SqlServer/Query/Internal/Translators/SqlServerByteArrayMethodTranslator.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteByteArrayMethodTranslator.cs
Show resolved
Hide resolved
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Closes #27113