[release/9.0-staging] Transform Span-based overloads to Enumerable in funcletizer #35719
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backports part of #35339
Fixes #35100
Description
C# 14 (currently in preview) is introducing first-class spans, which changes the Roslyn overload resolution to prefer Span-based overloads in some cases. Unfortunately, the newly selected overloads, which have Span parameters, are unsupported in EF since the LINQ expression tree interpreter is used internally, and it does not support ref structs.
This problem already been fixed for EF 10 in #35339. However, users on older of EF Core who switch to .NET 10/C# 14 will still hit this issue. This PR proposes backporting the fix to EF Core 9.0 to ensure these users aren't affected.
Customer impact
Some very basic query patterns will start failing when trying to use EF Core 9.0 with C# 14, e.g.:
How found
Reported by users on 10.
Regression
Yes, in the combination of EF Core 9.0 and C# 14.
Testing
Older versions of EF aren't tested with later versions of C#/NET; manual testing was performed.
Risk
Very low - very targeted expression tree transformation; added quirk.