Skip to content

Conversation

Copy link

Copilot AI commented Oct 12, 2025

Problem

This PR addresses a breaking change introduced in C# 14 (part of .NET 10) related to first-class spans. The issue affects code using params ReadOnlySpan<T> parameters when working with MongoDB's BSON serializer.

With C# 14's first-class spans feature, ReadOnlySpan<T> parameters become fully supported language constructs. However, spans are stack-allocated types that cannot be serialized. When the MongoDB driver attempts to serialize methods with params ReadOnlySpan<T> parameters, it throws:

System.NotSupportedException: 'Specified method is not supported.'

See the .NET Runtime issue and MongoDB JIRA CSHARP-5749 for more details.

Solution

This PR replaces params ReadOnlySpan<T> with params T[] in two methods:

  1. LiquidExtensions.GetTokens(): Changed from params ReadOnlySpan<Type> to params Type[]
  2. IFileStoreExtensions.Combine(): Changed from params ReadOnlySpan<string> to params string[]

Why This Works

  • Backward Compatible: All existing callers continue to work without modification
  • Forward Compatible: Works with .NET 10 and C# 14 without serialization errors
  • Serialization Safe: Arrays can be serialized by MongoDB's BSON serializer
  • Performance: Negligible performance difference for these use cases

Example

Existing code continues to work unchanged:

// Still works exactly the same
var tokens = LiquidExtensions.GetTokens(
    typeof(LiquidStore),
    typeof(LiquidCustomer),
    typeof(LiquidOrder)
);

Testing

  • ✅ Solution builds successfully with no warnings or errors
  • ✅ All existing method callers work without modification
  • ✅ No breaking changes to public API

Fixes compatibility with .NET 10 and prepares the codebase for C# 14.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • ccsca2021.crl.certum.pl
    • Triggering command: dotnet build GrandNode.sln --configuration Release (dns block)
  • ccsca2021.ocsp-certum.com
    • Triggering command: dotnet build GrandNode.sln --configuration Release (dns block)
  • crl.certum.pl
    • Triggering command: dotnet build GrandNode.sln --configuration Release (dns block)
  • subca.ocsp-certum.com
    • Triggering command: dotnet build GrandNode.sln --configuration Release (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>C# 14 breaking change heads up</issue_title>
<issue_description>Hey folks, as part of our smoke testing for .NET 10, we noticed that grandnode2 is affected by the breaking change in C# 14 around first-class spans. @jjonescz has a full writeup on the change here, and I've filed a bug on the MongoDB provider for the scenario here, but when you upgrade to .NET 10, at least some reaction to this will be needed, either to change your code to work around the issue as Jan described, or by upgrading to a version of the MongoDB driver that adapts to change. Otherwise, you will errors like System.NotSupportedException: 'Specified method is not supported.'.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #624


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Fix C# 14 breaking change for grandnode2 Fix C# 14 breaking change: Replace params ReadOnlySpan with params arrays Oct 12, 2025
Copilot AI requested a review from KrzysztofPajak October 12, 2025 17:05
Copilot finished work on behalf of KrzysztofPajak October 12, 2025 17:05
@sonarqubecloud
Copy link

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.

2 participants