-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Critical - P2
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
🔵 Done
-
Dotnet Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Summary
With Langversion 14, if you use a LINQ query with a Contains Method from an array it incorrectly compiles with ReadOnlySpan causes an error
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
3.5
How to Reproduce
The screenshot below demonstrate that, using the langversion 14 (.NET 10) if you create a query with an array and Contains it uses the ReadOnlySpan extensino method, making the LINQ driver to fail the translation with the error System.NotSupportedException: Specified method is not supported. (just run the attached example)Â Â **Â Â
Â
The proof that the ReadOnlySpan is the culprit is: take the project file, set the lang versino to 13
<LangVersion>13</LangVersion>
Then the compiler uses the IEnumerable extension and the translation is correct. This happens even in .NET 9 project if you have Langversion 14. The worst thing is, if you have
<LangVersion>latest</LangVersion>
Â
the code runs fine if compiled from VS2022 and has the error using the preview of VS2026.
Additional Background
If you use a List<String> instead of a string array everything is ok, if in the C# project file you use <langversion>13</langversion> the expression run correct.,y
- duplicates
-
CSHARP-5749 C# 14 breaking change heads up
-
- In Code Review
-