Skip to content

Conversation

roji
Copy link
Member

@roji roji commented Oct 19, 2025

This makes the provider filters compatible with C# 14 (see #12504, and dotnet/runtime#109757 on the runtime side). Note that this changes the entire repo to build with dotnet SDK 10.0 (rc2) - that's probably a good idea regardless to test with the latest, ensure compatibility etc. (but if this is problematic, let me know - it's only truly necessary for test coverage and can be reverted).

I'm not happy to have the implementation duplicated across the implementations: we have FilterTranslationPreprocessor for common LINQ filter preprocessing, and that would be the ideal place for this. However, rewriting MemoryExtensions.Contains to Enumerable.Contains would require doing MethodInfo.MakeGenericMethod which is incompatible with NativeAOT. I considered have a fake, non-invocable MethodInfo implementation to represent the closed generic MethodInfo to Enumerable.Contains (MethodInfo and Type are abstract, so we can create custom implementations compatible with NativeAOT), but that's quite involved/complicated. The better story here is probably to have a base class implementation for the provider filter processors, which recognizes specific patterns and dispatches to abstract handlers which specific implementations override; it would take care of recognizing the various Contains variants.

Note also that we already have duplication around Enumerable.Contains and List.Contains (the instance method), so this just adds another variant (for now). I'll think about cleaning this up.

Fixes #12504

@roji roji requested a review from a team as a code owner October 19, 2025 09:52
@markwallace-microsoft markwallace-microsoft added the .NET Issue or Pull requests regarding .NET code label Oct 19, 2025
@github-actions github-actions bot changed the title Support MemoryExtensions.Contains in LINQ filters .Net: Support MemoryExtensions.Contains in LINQ filters Oct 19, 2025
@roji roji changed the title .Net: Support MemoryExtensions.Contains in LINQ filters .Net: [MEVD] Support MemoryExtensions.Contains in LINQ filters Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.Net: [MEVD] Ensure Contains compatibility with C# 14 first-class spans

3 participants