diff --git a/src/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.MultiSegment.cs b/src/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.MultiSegment.cs index 51f8c786e6ff..8c268864775e 100644 --- a/src/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.MultiSegment.cs +++ b/src/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.MultiSegment.cs @@ -647,21 +647,13 @@ private bool ConsumeNumberMultiSegment() if (_consumed >= (uint)_buffer.Length) { - if (!_isNotPrimitive) - { - return true; - } - if (IsLastSpan || !GetNextSpan()) - { - ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.ExpectedEndOfDigitNotFound, _buffer[_consumed - 1]); - } - } + Debug.Assert(IsLastSpan); - // TODO: https://github.com/dotnet/corefx/issues/33294 - if (JsonConstants.Delimiters.IndexOf(_buffer[_consumed]) < 0) - { - ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.ExpectedEndOfDigitNotFound, _buffer[_consumed]); + ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.ExpectedEndOfDigitNotFound, _buffer[_consumed - 1]); } + + Debug.Assert(JsonConstants.Delimiters.IndexOf(_buffer[_consumed]) >= 0); + return true; } @@ -1306,7 +1298,7 @@ private ConsumeNumberResult ConsumeZeroMultiSegment(ref ReadOnlySpan data, if (IsLastSpan) { // A payload containing a single value: "0" is valid - // If we are v with multi-value JSON, + // If we are dealing with multi-value JSON, // ConsumeNumber will validate that we have a delimiter following the "0". return ConsumeNumberResult.Success; } diff --git a/src/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.cs b/src/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.cs index f307cb2ea2d0..b6e8f2fc5039 100644 --- a/src/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.cs +++ b/src/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.cs @@ -694,22 +694,13 @@ private bool ConsumeNumber() if (_consumed >= (uint)_buffer.Length) { - if (!_isNotPrimitive) - { - return true; - } - if (IsLastSpan) - { - ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.ExpectedEndOfDigitNotFound, _buffer[_consumed - 1]); - } - return false; - } + Debug.Assert(IsLastSpan); - // TODO: https://github.com/dotnet/corefx/issues/33294 - if (JsonConstants.Delimiters.IndexOf(_buffer[_consumed]) < 0) - { - ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.ExpectedEndOfDigitNotFound, _buffer[_consumed]); + ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.ExpectedEndOfDigitNotFound, _buffer[_consumed - 1]); } + + Debug.Assert(JsonConstants.Delimiters.IndexOf(_buffer[_consumed]) >= 0); + return true; } @@ -1067,7 +1058,7 @@ private ConsumeNumberResult ConsumeZero(ref ReadOnlySpan data, ref int i) if (IsLastSpan) { // A payload containing a single value: "0" is valid - // If we are v with multi-value JSON, + // If we are dealing with multi-value JSON, // ConsumeNumber will validate that we have a delimiter following the "0". return ConsumeNumberResult.Success; }