Skip to content

Conversation

@roji
Copy link
Member

@roji roji commented Feb 9, 2026

Closes #27113

@roji roji marked this pull request as ready for review February 9, 2026 15:13
@roji roji requested a review from a team as a code owner February 9, 2026 15:13
Copilot AI review requested due to automatic review settings February 9, 2026 15:13
Copy link

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

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/MemberInfo caches with DeclaringType/Name checks (often with list-pattern argument validation).
  • Convert many translators to primary-constructor style and remove backing _sqlExpressionFactory fields 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).

@roji roji enabled auto-merge (squash) February 9, 2026 21:53
@roji
Copy link
Member Author

roji commented Feb 10, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@roji
Copy link
Member Author

roji commented Feb 10, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

Stop eagerly loading methods/members via reflection which aren't necessarily needed

1 participant