Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 9, 2026

Description

Updates the internal DumpHeaders method signature to use C# 12's params ReadOnlySpan<T> instead of params array, avoiding heap allocation for the params array.

- internal static void DumpHeaders(ref ValueStringBuilder sb, params HttpHeaders?[] headers)
+ internal static void DumpHeaders(ref ValueStringBuilder sb, params ReadOnlySpan<HttpHeaders?> headers)

Customer Impact

None. Internal method only, no API surface change.

Regression

No.

Testing

Build verified (0 warnings, 0 errors). Method is internal with 3 call sites in HttpRequestMessage.ToString() and HttpResponseMessage.ToString().

Risk

Low. Single line signature change with semantically equivalent behavior.

Package authoring no longer needed in .NET 9

IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.

Original prompt

Please update DumpHeaders to take a params span instead of params array.


💡 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.

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot AI changed the title [WIP] Update DumpHeaders to take params span instead of array Update DumpHeaders to take params span instead of params array Jan 9, 2026
Copilot AI requested a review from stephentoub January 9, 2026 14:25
@stephentoub stephentoub marked this pull request as ready for review January 9, 2026 14:29
Copilot AI review requested due to automatic review settings January 9, 2026 14:29
@stephentoub stephentoub enabled auto-merge (squash) January 9, 2026 14:29
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the internal DumpHeaders method signature to use C# 12's params ReadOnlySpan<HttpHeaders?> instead of params array, eliminating heap allocation for the params array while maintaining identical semantics.

  • Single line signature change from params array to params ReadOnlySpan
  • All 3 call sites remain unchanged and compatible with the new signature
  • Method implementation already uses only span-compatible operations (Length, indexer)

@stephentoub stephentoub merged commit 6ad5642 into main Jan 9, 2026
98 of 99 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants