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.
@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.
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.WriteCommentValuehandling 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: