Skip to content

Pass interpolated string handlers by ref #57538

@stephentoub

Description

@stephentoub

Background and motivation

Our default interpolated string handler, StringBuilder handler, and MemoryExtensions handler are all passed to their target methods by ref. But we neglected to do so for the Debug handlers; we should update those signatures as well.

Benefits:

  • Consistency across all our handlers
  • These are typically larger structs and so by ref helps (though it doesn’t matter for Debug)
  • Making it a ref makes it even less attractive to try to call directly / makes it look even more special
  • It gives us the opportunity to more safely clean up at the end of the operation

API Proposal

See the ref updates here:
https://github.com/dotnet/runtime/pull/57536/files#diff-cec8e6f471b4193246bdc0107b0dd7cbe131fb7fd189b288b37269c333d1171d

API Usage

No usage difference when using interpolated string syntax, which is how we expect these APIs to be used.

Risks

This is a breaking change from .NET 6 Preview 7.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions