C# 14 breaking change heads up

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: 3.2.1
    • Component/s: LINQ
    • None
    • Dotnet Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      A C# 14 breaking change is likely to affect a number of customers using the MongoDB driver who upgrade to .NET 10 or manually turn on C# 14; we already have an example of this in grandnode2 that we build as part of smoke testing. The change causes Span/ReadOnlySpan {}extension methods to be preferred for arrays over {{IEnumerable }}extensions, which can change what methods appear in an expression tree. EF Core handled this here: Update dependencies and transform Span-based overloads to Enumerable in funcletizer by roji · Pull Request #35339 · dotnet/efcore. We suggest that MongoDB takes the same approach. While the repro we have used the 3.2.1 driver, we expect that any version will have this issue unless the breaking change is addressed or users update their code to work around it.

       

      The resulting queries from this breaking change will fail with `System.NotSupportedException: 'Specified method is not supported.`

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

      How to Reproduce

      Create any expression that has an arrayValue.Contains(elementToSearchFor). This will bind to a new method that uses a ref struct, rather than Enumerable.Contains, and that will fail to be run by the driver. One example is this query from the grandnode2 repository: Grandnode2 failed to compile here: grandnode2/src/Business/Grand.Business.Customers/Queries/Handlers/GetCustomerQueryHandler.cs at main · grandnode/grandnode2..

      Additional Background

      [dotnet-sdk-10.0.100-rc.2.25474.116] grandnode2 launch failed with error: System.NotSupportedException: 'Specified method is not supported.' · Issue #120251 · dotnet/runtime is the specific regression we saw during scouting runs, and has more details on both the C# change and the cause. 

            Assignee:
            Damien Guard
            Reporter:
            Fred Silberberg
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: