Skip to content

Pass interpolated string handlers by ref #57538

Closed

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.

Activity

  1. added
    blocking
    api-ready-for-review
    on Aug 17, 2021
  2. added this to the 6.0.0 milestone on Aug 17, 2021
  3. ghost added
    untriaged
    on Aug 17, 2021
  4. removed
    untriaged
    on Aug 17, 2021
  5. self-assigned this
    on Aug 17, 2021
  6. added
    in-pr
    on Aug 17, 2021
  7. bartonjs commented on Aug 17, 2021

    @bartonjs
    Member

    Video

    Looks good as proposed. Hopefully we'll be diligent in the future at always using pass-by-ref when the handler is a struct.

  8. added
    api-approved
    and removed
    blocking
    api-ready-for-review
    on Aug 17, 2021
  9. ghost removed
    in-pr
    on Aug 17, 2021
  10. ghost locked as resolved and limited conversation to collaborators on Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api-approvedarea-System.Runtime

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions