Skip to content

Add fix for .NET 10 first-class span support#2345

Merged
roji merged 7 commits intodotnet:mainfrom
eaze:add-memoryextensions.contains-native-span-support
Jan 22, 2026
Merged

Add fix for .NET 10 first-class span support#2345
roji merged 7 commits intodotnet:mainfrom
eaze:add-memoryextensions.contains-native-span-support

Conversation

@ericsampson
Copy link
Copy Markdown
Contributor

@ericsampson ericsampson commented Dec 29, 2025

See:

This PR is as direct of a port of @roji's original .EF Core fix as I could make it, with minor adjustments as required by EF6.

I added unit tests that demonstrated failure before the fix and success on all cases afterwards.

Thanks for the help hopefully getting this into EF6!
Cheers,
Eric

…d resolution (MemoryExtensions vs Enumerable) resulting in breakage.
@ericsampson
Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree company="Microsoft"

Copy link
Copy Markdown
Member

@roji roji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ericsampson, the PR generally looks quite good.

However, the bar for any changes to EF6 is very high, and as very few users have been complaining about this issue, we weren't planning on fixing this problem at this time. I'll bring this up internally and we'll see what to do.

Comment thread src/EntityFramework/Core/Objects/ELinq/LinqExpressionNormalizer.cs Outdated
Comment thread test/UnitTests/UnitTests.csproj
@roji
Copy link
Copy Markdown
Member

roji commented Dec 30, 2025

Note also the build failures.

@ericsampson
Copy link
Copy Markdown
Contributor Author

the bar for any changes to EF6 is very high, and as very few users have been complaining about this issue, we weren't planning on fixing this problem at this time. I'll bring this up internally and we'll see what to do.

@roji I totally understand. I was hoping to just reduce the "activation energy" by providing a working PR for you folks to consider rather than expecting someone from MSFT to do it, as it would likely not meet prioritization or at least not anytime soon.

The build issue should be addressed. Last time the build queue was taking so long to pick up the job that I had to just walk away and let it get picked up overnight, so that's why I didn't fix the failure immediately. Looks like the fix is now in the same queue waiting game state :)

Cheers

The UnitTests project was designed for .NET Framework and has extensive
dependencies on Framework-specific infrastructure. Rather than exclude
hundreds of incompatible tests, whitelist only the Span-related tests
needed to verify the MemoryExtensions rewrite logic on .NET 10+.
@ericsampson
Copy link
Copy Markdown
Contributor Author

@roji CI tests are passing now :)

Copy link
Copy Markdown
Member

@roji roji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks almost ready (good work!). A couple of small fixes and I'll merge it.

Just to clearly set expectations; for now, although we'll be merging this PR, we won't be releasing a new version of EF6 in the immediate future. In principle, new versions of EF6 are only being released for security fixes, which this isn't. Based on feedback we can reevaluate.

Comment thread src/EntityFramework/Core/Objects/ELinq/LinqExpressionNormalizer.cs Outdated
Comment thread eng/Versions.props Outdated
@ericsampson
Copy link
Copy Markdown
Contributor Author

Thanks @roji addressed the feedback; I have one suggestion for y'all to consider:

What about publishing this to NuGet as 6.6.1-alpha ? That would:

  1. allow people hitting this issue to pull down a package version containing the fix, without them having to clone down and publish to their own private NuGet (if they even have one)
  2. give package download counts to help future impact estimation etc,
    and at the same avoid violating the "it's not a security fix and so doesn't meet the bar for a new release" guidance.

Thoughts?
Happy 2026,
Eric

@ericsampson ericsampson requested a review from roji January 12, 2026 23:17
Copy link
Copy Markdown
Member

@roji roji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ericsampson, LGTM.

Comment thread test/UnitTests/UnitTests.csproj Outdated
@ErikEJ
Copy link
Copy Markdown
Contributor

ErikEJ commented Jan 13, 2026

@ericsampson @roji Just to be clear, this PR is to enable EF6 to run under .NET 10 without making any code changes when .Contains is used in LINQ queries?

@ericsampson
Copy link
Copy Markdown
Contributor Author

ericsampson commented Jan 13, 2026

@ericsampson @roji Just to be clear, this PR is to enable EF6 to run under .NET 10 without making any code changes when .Contains is used in LINQ queries?

@ErikEJ EF6 as-is works in .NET 10 IF you set the langversion to <=13.

This PR will allow EF6 using .Contains to work on .NET 10 with C# 14+ (as would typically happen in an app upgrade scenario where the langversion isn't pinned to a specific numbered version).

I think I've stated that correctly :)

@ericsampson
Copy link
Copy Markdown
Contributor Author

@roji should I merge this in? Or do you want to. What do you think of the idea of publishing this to NuGet as 6.6.1-alpha ? It would allow people that are affected to pull down a working fix for their apps, without having to wait for an unknown amount of time before the next security patch release. Cheers

@kmc059000
Copy link
Copy Markdown

My team has hit this issue and is preventing our ability to upgrade to C#14 which we would like to do. It is a pretty big blocker for us.

@bkzoller
Copy link
Copy Markdown

This is blocking us from upgrading to C# 14. Luckily we were alerted to this problem with hundreds of test failures in the CI pipeline from simply switching from C# 13 to C# 14. This is a potential landmine for any projects using EF6 and .NET 10 together without such test coverage.

@roji roji merged commit 9b0bcd2 into dotnet:main Jan 22, 2026
2 checks passed
@roji
Copy link
Copy Markdown
Member

roji commented Jan 22, 2026

@ericsampson I just merged this - thanks again for the contribution. We'll discuss internally about when a new version can be released with this fix.

@bkzoller you don't have to use C# 14 when upgrading to .NET 10 - it's perfectly fine to upgrade to .NET 10 but keep your C# language at 13. If there's some C# 14 feature you absolutely must have, as a workaround you can also modify your queries which use Contains over an array to e.g. do it over a List instead.

@ericsampson
Copy link
Copy Markdown
Contributor Author

Thanks @roji, appreciate your reviews and suggestions. Cheers!

@PaulVrugt
Copy link
Copy Markdown

@roji @ericsampson not sure who to tag here, but this merge is useless without a new release on nuget. What are the plans for releasing this?

@roji
Copy link
Copy Markdown
Member

roji commented Feb 24, 2026

@PaulVrugt unfortunately this will take a bit more, as we have a lot of things going on and this requires some non-trivial work.

Copilot AI added a commit that referenced this pull request Mar 5, 2026
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
AndriySvyryd added a commit that referenced this pull request Mar 6, 2026
Port of #2345:

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
SocSoftSpb added a commit to SocSoftSpb/EntityFramework6 that referenced this pull request Mar 10, 2026
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.

6 participants