-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Remove custom Utf8 encoder implementation #77400
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
Remove custom Utf8 encoder implementation #77400
Conversation
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsSecond attempt at replacing JsonWriterHelper.Transcoding.cs Fix #75779
|
cc @kasperk81 |
Added When you commit this breaking change:
Tagging @dotnet/compat for awareness of the breaking change. |
try | ||
{ | ||
#if NETCOREAPP | ||
s_utf8Encoding.GetCharCount(bytes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GrabYourPitchforks, I thought we had a Utf8.IsValid API, but I can't find it now in either source or an issue. Am I making it up? Is that something we plan to expose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like roslyn is also using similar method for CS9026
diagnostics in ""u8
strings lowering: https://github.com/dotnet/roslyn/blob/ab7dd82/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Conversion.cs#L113
IsValid(ReadOnly<byte>)
is a good candidate API for System.Text.Unicode.Utf8
type. :)
I don't believe this warrants a breaking change document, the implementation been changed to reject invalid UTF-8 (invalid surrogate pairs) which were previously being accepted. |
Second attempt at replacing JsonWriterHelper.Transcoding.cs
Note that this PR changes
Utf8JsonWriter.WriteCommentValue
handling of inputs that result in invalid UTF-8 outputs, so technically this introduces a breaking change cc @GrabYourPitchforks @bartonjsFix #75779
Change is recording hefty performance improvements in the string writing benchmarks: