Add side-effect free debugger display to ValueStringBuilder.#122265
Merged
ViveliDuCh merged 3 commits intodotnet:mainfrom Jan 14, 2026
Merged
Add side-effect free debugger display to ValueStringBuilder.#122265ViveliDuCh merged 3 commits intodotnet:mainfrom
ValueStringBuilder.#122265ViveliDuCh merged 3 commits intodotnet:mainfrom
Conversation
Calling `ToString()` clears the builder, which can cause surprises when debugging.
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-runtime |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a side-effect free debugger display to both versions of ValueStringBuilder to address the problematic behavior where calling ToString() clears the builder, which causes unexpected issues during debugging.
Key changes:
- Added
[DebuggerDisplay]attribute to bothValueStringBuilderandValueStringBuilder<TChar>structs - Created side-effect free
DebuggerDisplayproperties that display the builder's content without clearing it - Refactored
ValueStringBuilder<TChar>.ToString()to extract string generation logic into a separateGetString()method
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/libraries/Common/src/System/Text/ValueStringBuilder.cs | Added [DebuggerDisplay] attribute and DebuggerDisplay property that uses AsSpan().ToString() for side-effect free debugging |
| src/libraries/Common/src/System/Text/ValueStringBuilder_1.cs | Added [DebuggerDisplay] attribute, extracted GetString() method for reuse, and added DebuggerDisplay property that calls GetString() for side-effect free debugging |
stephentoub
reviewed
Dec 7, 2025
ViveliDuCh
approved these changes
Jan 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Calling
ToString()clears the builder, which can cause surprises when debugging.