Skip to content
New issue

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

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

Already on GitHub? # to your account

Add DefaultInterpolatedStringHandler.Text/Clear #112171

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stephentoub
Copy link
Member

Fixes #110505

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Feb 5, 2025
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@TrayanZapryanov
Copy link
Contributor

I am wondering if concerns about exposing ValueStringBuilder are not applicable here too. Soon I've copied ValueStingBuilder in our codebase and build a handler like DefaultInterpolatedStringHandler but storage was VSB. Then was asked by colleagues what will happen if they forgot about calling Clear(Dispose in our case).

@stephentoub
Copy link
Member Author

Then was asked by colleagues what will happen if they forgot about calling Clear(Dispose in our case).

An ArrayPool array may not be returned to the pool.

@stephentoub stephentoub added area-System.Runtime.CompilerServices and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Feb 5, 2025
@stephentoub stephentoub requested a review from mgravell February 19, 2025 15:58
@@ -13418,6 +13418,8 @@ public void AppendFormatted<T>(T value, int alignment) { }
public void AppendFormatted<T>(T value, int alignment, string? format) { }
public void AppendFormatted<T>(T value, string? format) { }
public void AppendLiteral(string value) { }
public void Clear() { throw null; }
Copy link
Member

@mgravell mgravell Feb 19, 2025

Choose a reason for hiding this comment

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

Nit: isn't the convention just { } if there's no return/out?

Suggested change
public void Clear() { throw null; }
public void Clear() { }

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API Proposal]: DefaultInterpolatedStringHandler - expose buffer and reset
3 participants