Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all interpolated string handlers pass by ref #57536

Merged
merged 2 commits into from
Aug 17, 2021

Commits on Aug 17, 2021

  1. Make all interpolated string handlers pass by ref

    We currently pass all of our interpolated string handlers to their destination methods by ref, with the exception of those for Debug.  I think it makes sense to centralize on the pattern of always passing by ref: it doesn’t negatively impact the user experience, 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, and most importantly, it gives us the opportunity to more safely clean up at the end of the operation.  This changes the Debug.Assert/Write{Line}If overloads we added in Preview 7 to pass the handler’s by ref.
    
    This also then updates the Debug.Write{Line}If methods to create the StringBuilder used via StringBuilderCache, just in case these are used in a scenario where true is frequently passed.
    stephentoub committed Aug 17, 2021
    Configuration menu
    Copy the full SHA
    203c228 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f8da522 View commit details
    Browse the repository at this point in the history