Remove a few more instances of unsafe code in STJ - #114490
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
src/libraries/Common/src/System/Text/ValueStringBuilder.cs:237
- Removal of the unsafe Append overload is appropriate; ensure that all call sites have been updated to use the Append(ReadOnlySpan) overload so that functionality and performance are maintained.
public unsafe void Append(char* value, int length)
EgorBo
commented
Apr 10, 2025
| { | ||
| return string.Create(bytes.Length * 2, (RosPtr: (IntPtr)(&bytes), casing), static (chars, args) => | ||
| EncodeToUtf16(*(ReadOnlySpan<byte>*)args.RosPtr, chars, args.casing)); | ||
| } |
Member
Author
There was a problem hiding this comment.
This will be removed once we stop building for net8.0 (this november?)
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis |
This was referenced Apr 10, 2025
Member
Author
|
@stephentoub @eiriktsarpalis PTAL, a small follow up |
eiriktsarpalis
approved these changes
Apr 11, 2025
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.
Follow up to #114154
With that,
System.Text.Json.csproj(for net10 target) needs unsafe context only for two things:JavaScriptEncoder.FindFirstCharacterToEncode(char*, int)- filed an API proposal - [API Proposal]: TextEncoder.FindFirstCharacterToEncode(ReadOnlySpan<char>) #114423SkipLocalsInitrequires AllowUnsafeBlocks. If we remove the attribute jit-diffs will look like this:(looks like mostly just inlined stackalloc zeroing)