Formatting and parsing changes to JsonString (dotnet/corefx#41940)
authorKristian Hellang <kristian@hellang.com>
Fri, 1 Nov 2019 20:10:04 +0000 (21:10 +0100)
committerStephen Toub <stoub@microsoft.com>
Fri, 1 Nov 2019 20:10:04 +0000 (16:10 -0400)
commit17f59b60e2f6cdd965307b61112f98db53970664
treebe5299303488427e96fbd29329ccef1a01683833
parent3dab825594eca2b66f9d29f80308104f7d6c9231
Formatting and parsing changes to JsonString (dotnet/corefx#41940)

* Pull duplicated code into JsonWriterHelper

* Add helpers for parsing and formatting ISO dates

* Update tests to expect new format

* Use new helpers in JsonString methods

* Rename methods

* Check for valid parse length

* Use AsSpan extension to work around missing implicit operators on netfx

* More netfx workarounds

* Use constant for stackalloc length

* Add back temp span to avoid writing too much when trimming

* Move IsValidDateTimeOffsetParseLength to JsonHelpers

* Always use StackallocThreshold instead of calling GetUtf8ByteCount

* Remove redundant length checks done by IsValidDateTimeOffsetParseLength

* Adapt test pattern from Utf8JsonWriterTests

* Revert "Always use StackallocThreshold instead of calling GetUtf8ByteCount"

This reverts commit dotnet/corefx@0d29b646166138413f311a3ccf6284a72024b439.

Commit migrated from https://github.com/dotnet/corefx/commit/21fd4d2a70447064aacb6536278f6e8cc1c9e2d5
12 files changed:
src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.cs
src/libraries/System.Text.Json/src/System/Text/Json/JsonHelpers.Date.cs
src/libraries/System.Text.Json/src/System/Text/Json/Node/JsonString.cs
src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.cs
src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.TryGet.cs
src/libraries/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.Date.cs
src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.WriteProperties.DateTime.cs
src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.WriteProperties.DateTimeOffset.cs
src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.WriteValues.DateTime.cs
src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.WriteValues.DateTimeOffset.cs
src/libraries/System.Text.Json/tests/JsonObjectTests.cs
src/libraries/System.Text.Json/tests/JsonStringTests.cs