Add tests for custom JavaScriptEncoder to cover the virtual code paths in TextEncoder, and address previous feedback.#42064
Conversation
src/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.Escaping.cs
Show resolved
Hide resolved
src/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.Escaping.cs
Show resolved
Hide resolved
|
|
||
| private static readonly Vector128<short> s_mask_UInt16_0x00 = Vector128<short>.Zero; // Null | ||
|
|
||
| private static readonly Vector128<short> s_mask_UInt16_0x20 = Vector128.Create((short)0x20); // Space ' ' |
There was a problem hiding this comment.
Renaming these to address some of the leftover feedback from #41845 (comment)
There was a problem hiding this comment.
Thanks for the hint -- I'll incorporate this, so no conflict will occur.
src/System.Text.Encodings.Web/src/System/Text/Encodings/Web/DefaultJavaScriptEncoder.cs
Show resolved
Hide resolved
src/System.Text.Encodings.Web/src/System/Text/Encodings/Web/Sse2Helper.cs
Show resolved
Hide resolved
src/System.Text.Encodings.Web/src/System/Text/Encodings/Web/Sse2Helper.cs
Show resolved
Hide resolved
| private static readonly Vector128<sbyte> s_mask_SByte_0x3E = Vector128.Create((sbyte)0x3E); // Greater Than Sign '>' | ||
| private static readonly Vector128<sbyte> s_mask_SByte_0x5C = Vector128.Create((sbyte)0x5C); // Reverse Solidus '\' | ||
| private static readonly Vector128<sbyte> s_mask_SByte_0x60 = Vector128.Create((sbyte)0x60); // Grave Access '`' | ||
| private static readonly Vector128<short> s_nullMaskInt16 = Vector128<short>.Zero; |
There was a problem hiding this comment.
Since this is in the context of characters, I have been using character names. In this case, that's null (not zero, which just happens to be the value):
https://www.fileformat.info/info/unicode/char/0000/index.htm
I can see why using zero could be useful (similar to using s_maxAsciiCharacterMaskInt16 rather than delete for 0x7F), but not sure if it's worth changing.
There was a problem hiding this comment.
null reminds me of null 😉
The vector consists of 0s, so zero. It's usage is in CompareLessThan so it's more a comparison against a value, rather than null.
But this is more or less a quibble, and so it's up to you whether it's changed or not.
…s in TextEncoder, and address previous feedback. (dotnet/corefx#42064) * Move using directive within ifdef to make it clear when its used. * Add more tests for custom text encoder case. * Fix typo in comment gaurd -> guard * Fix up the using directives that got removed during merge conflict resolution. * Address feedback - fix 0x7F case, rename vectors to be self-documenting. Commit migrated from dotnet/corefx@62e6ccf
Adding some of the new tests from #42030 into master and fix some nits.
cc @GrabYourPitchforks, @tarekgh