-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[release/8.0-staging] Handle .NET 10 MemoryExtensions.Contains overload with comparer #37182
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
|
/cc @artl93 for initial servicing approval. |
b86eb94 to
394d51c
Compare
|
Approved for me. How often do we see regressions like this across versions of .NET? |
|
With the changes needed, should we be running a full test pass on 9.0 and 8.0 - like mock it up in a PR? |
394d51c to
ce301fc
Compare
Very rarely... There's an inherent increased brittleness with metaprogramming techniques (LINQ providers, Roslyn analyzers/source generators) which operate on representations of user code: any change in overload resolution or similar change in the code representation can trigger a failure. But we almost never see actual such breaks across .NET versions.
Yeah, that's a good idea - though it seems like it's a bit complicated/non-trivial to have our CI do EF8/9 with .NET 10 (see #37186). I ran some relevant testing locally and will also do the entire SQLite/SQL Server test suites. |
|
Looks good to me |
| private static readonly bool UseOldBehavior37176 = | ||
| AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue37176", out var enabled37176) && enabled37176; |
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.
Can't you just reuse the above one? Seems like overkill to add a switch for each method
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.
Well technically these are two separate changes... this new one only fixes additional recognition for MemoryExtensions.Contains, and in theory could be problematic, causing users to need to roll back without also rolling back the general MemoryExtensions.Contains support.
I tend not to worry too much about quirks (they're in servicing branches only), but if you really prefer it I'll remove the new switch and keep only the existing one for MemoryExtensions.Contains.
ce301fc to
9a56807
Compare
Fixes #37176 for EF 8.0 (see #37183 for 8.0 fix)
Description
C# 14 first-class spans causes MemoryExtensions.Contains instead of Enumerable.Contains to be resolved, forcing LINQ providers to identify the former in additional to the latter. In addition, .NET 10 introduced a 3-parameter overload to MemoryExtensions.Contains which accepts a comparer, that gets resolved in some situations. While we already backported support for MemoryExtensions.Contains to EF Core 8 and 9, to allow these versions to work with C# 14, we didn't backport a separate change to also support the new .NET 10 overload.
Customer impact
Customers upgrading to .NET 10 but staying on EF 8 or 9 start experiencing failures in some LINQ queries that use Contains. The common case is Contains over an enum array:
Customers upgrading to EF 10 are not affected.
How found
Multiple customers reported on 9.0
Regression
Partial: occurs only when upgrading to .NET 10 but keeping older EF 8 or 9.
Testing
Tested manually, as we don't have automated testing for .NET 10 on older EF versions.
Risk
Very low, targeted change that's very low-risk, and already well-tested in EF 10. Quirk added.