Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 6, 2025

The Roslyn 4.14.0 compiler update introduced stricter type checking for MemoryMarshal.Cast when called directly on arrays, now returning ReadOnlySpan<T> instead of Span<T>.

Changes

  • JsonDocument.MetadataDb.cs: Explicitly convert byte array to Span<byte> before casting to Span<int> to preserve write access
// Before
Span<int> newDbInts = MemoryMarshal.Cast<byte, int>(newDatabase);

// After  
Span<int> newDbInts = MemoryMarshal.Cast<byte, int>(newDatabase.AsSpan());

The writable span is required since the code modifies elements via newDbInts[i] -= locationOffset.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Update dependencies from dotnet/roslyn Fix MemoryMarshal.Cast implicit conversion error after Roslyn update Nov 6, 2025
Copilot AI requested a review from sbomer November 6, 2025 17:59
Copilot finished work on behalf of sbomer November 6, 2025 17:59
@sbomer sbomer marked this pull request as ready for review November 6, 2025 18:02
@sbomer sbomer merged commit df29b24 into darc-release/9.0-staging-4da6a74f-9a77-4837-ae86-0b0dfcd7a5bd Nov 6, 2025
9 of 11 checks passed
@jkotas jkotas deleted the copilot/sub-pr-121343 branch November 12, 2025 05:16
sbomer added a commit that referenced this pull request Nov 14, 2025
…121601)

Fixes compilation error introduced by Roslyn 4.14.0's stricter type
checking for array-to-span conversions.

main PR: #121343

# Description

Roslyn 4.14.0 no longer allows implicit conversion from `string[]` to
`Span<string?>`. Fixed by explicitly converting arrays to spans in
`HttpHeaders.GetStoreValuesIntoStringArray`:

```csharp
// Before
ReadStoreValues<object?>(values, info.ParsedAndInvalidValues, descriptor.Parser, ref currentIndex);

// After  
ReadStoreValues<object?>(values.AsSpan(), info.ParsedAndInvalidValues, descriptor.Parser, ref currentIndex);
```

# Customer Impact

Blocks servicing release builds. No runtime behavior change.

# Regression

No - compiler enforcement tightening from dependency update.

# Testing

Verified compilation fix. No functional changes to test.

# Risk

Minimal. Surgical two-line change converts array to span where method
signature already required it. Identical pattern to fixes in #121414 and
BigInteger.cs (46bb931).

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: sbomer <[email protected]>
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