[API Proposal]: Add no-allocation span-based methods to StringInfo#125070
Closed
[API Proposal]: Add no-allocation span-based methods to StringInfo#125070
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/runtime-infrastructure |
Member
|
This PR is just testing out the API design skill. |
…lements to StringInfo Co-authored-by: ericstj <8918108+ericstj@users.noreply.github.com>
…mprove test coverage Co-authored-by: ericstj <8918108+ericstj@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Propose API changes for issue 123092
[API Proposal]: Add no-allocation span-based methods to StringInfo
Mar 2, 2026
Member
|
Seems like the publishing failed but it updated this PR with the proposal details. |
This was referenced Mar 2, 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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
StringInfolacks allocation-free APIs for counting grapheme clusters and extracting text-element ranges. The existingLengthInTextElementsbuilds a cachedint[], andSubstringByTextElementsalways allocates astring. This prototype implements three new APIs to close these gaps.New APIs
Contract:
GetRangeByTextElements/RangeByTextElementsthrowArgumentOutOfRangeExceptionfor negative arguments; returnnullwhen the requested range extends beyond the end of the string.Usage
Open questions for API review
Range?return vs.bool TryGetRangeByTextElements(…, out Range)stringoverloads are needed forGetLengthInTextElementsRangeByTextElements(int startingTextElement)(to end of string) should be addedPrototype commit
1409ae6
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/graphql/usr/bin/gh gh pr comment 125070 --body-file /tmp/proposal.md n.Metadata/src/System/Reflection/Metadata/Internal/StringHeap.cs n.Metadata/src/System/Reflection/Metadata/Internal/BlobHeap.cs n.Metadata/src/S/home/REDACTED/work/runtime/runtime/.dotnet/dotnet n.Metadata/src/S/home/REDACTED/work/runtime/runtime/.dotnet/sdk/11.0.100-preview.1.261�� n.Metadata/src/S/noautoresponse n.Metadata/src/S/nologo n.Me�� n.Metadata/src/S/nodeReuse:true n.Metadata/src/S/low:false System.Security.Cryptography/src/home/REDACTED/work/runtime/runtime/src/libraries/System.Private.C-t System.Security.git System.Security.push System.Security.-v System.Security.origin(http block)If you need me to access, download, or install something from one of these locations, you can either:
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.