1247 references to JsonConstants
System.Text.Json (1247)
src\libraries\System.Text.Json\Common\JsonSeparatorNamingPolicy.cs (2)
38Span<char> destination = initialBufferLength <= JsonConstants.StackallocCharThreshold 39? stackalloc char[JsonConstants.StackallocCharThreshold]
System\Text\Json\Document\JsonDocument.cs (11)
311int length = checked(otherText.Length * JsonConstants.MaxExpansionFactorWhileTranscoding); 312Span<byte> otherUtf8Text = length <= JsonConstants.StackallocByteThreshold ? 313stackalloc byte[JsonConstants.StackallocByteThreshold] : 360if (otherUtf8Text.Length < segment.Length / JsonConstants.MaxExpansionFactorWhileEscaping) 365int idx = segment.IndexOf(JsonConstants.BackSlash); 412Debug.Assert(segment.IndexOf(JsonConstants.BackSlash) == -1); 681Debug.Assert(segment.IndexOf(JsonConstants.BackSlash) == -1); 716Debug.Assert(segment.IndexOf(JsonConstants.BackSlash) == -1); 739if (segment.Length > JsonConstants.MaximumEscapedGuidLength) 751Debug.Assert(segment.IndexOf(JsonConstants.BackSlash) == -1); 753if (segment.Length == JsonConstants.MaximumFormatGuidLength
System\Text\Json\Document\JsonDocument.Parse.cs (7)
668s_falseLiteral ??= Create(JsonConstants.FalseValue.ToArray()); 671s_trueLiteral ??= Create(JsonConstants.TrueValue.ToArray()); 675s_nullLiteral ??= Create(JsonConstants.NullValue.ToArray()); 757ReadOnlySpan<byte> utf8Bom = JsonConstants.Utf8Bom; 842int utf8BomLength = JsonConstants.Utf8Bom.Length; 862Debug.Assert(rented.Length >= JsonConstants.Utf8Bom.Length); 871JsonConstants.Utf8Bom.SequenceEqual(rented.AsSpan(0, utf8BomLength)))
System\Text\Json\Document\JsonDocument.TryGetProperty.cs (4)
30if (maxBytes < JsonConstants.StackallocByteThreshold) 32Span<byte> utf8Name = stackalloc byte[JsonConstants.StackallocByteThreshold]; 142Span<byte> utf8UnescapedStack = stackalloc byte[JsonConstants.StackallocByteThreshold]; 174int idx = currentPropertyName.IndexOf(JsonConstants.BackSlash);
System\Text\Json\JsonEncodedText.cs (2)
83Span<byte> utf8Bytes = expectedByteCount <= JsonConstants.StackallocByteThreshold ? 84stackalloc byte[JsonConstants.StackallocByteThreshold] :
System\Text\Json\JsonHelpers.cs (2)
230Span<char> charBuffer = utf8Key.Length <= JsonConstants.StackallocCharThreshold ? 231stackalloc char[JsonConstants.StackallocCharThreshold] :
System\Text\Json\JsonHelpers.Date.cs (36)
25public bool OffsetNegative => OffsetToken == JsonConstants.Hyphen; 32return IsInRangeInclusive(length, JsonConstants.MinimumDateTimeParseLength, JsonConstants.MaximumEscapedDateTimeOffsetParseLength); 38return IsInRangeInclusive(length, JsonConstants.MinimumDateTimeParseLength, JsonConstants.MaximumDateTimeOffsetParseLength); 55if (parseData.OffsetToken == JsonConstants.UtcOffsetToken) 59else if (parseData.OffsetToken == JsonConstants.Plus || parseData.OffsetToken == JsonConstants.Hyphen) 88if (parseData.OffsetToken == JsonConstants.UtcOffsetToken || // Same as specifying an offset of "+00:00", except that DateTime's Kind gets set to UTC rather than Local 89parseData.OffsetToken == JsonConstants.Plus || parseData.OffsetToken == JsonConstants.Hyphen) 174if (source[4] != JsonConstants.Hyphen 176|| source[7] != JsonConstants.Hyphen 232if (source[10] != JsonConstants.TimePrefix || source[13] != JsonConstants.Colon 252case JsonConstants.UtcOffsetToken: 253parseData.OffsetToken = JsonConstants.UtcOffsetToken; 255case JsonConstants.Plus: 256case JsonConstants.Hyphen: 259case JsonConstants.Colon: 285case JsonConstants.UtcOffsetToken: 286parseData.OffsetToken = JsonConstants.UtcOffsetToken; 288case JsonConstants.Plus: 289case JsonConstants.Hyphen: 292case JsonConstants.Period: 308int fractionEnd = Math.Min(sourceIndex + JsonConstants.DateTimeParseNumFractionDigits, source.Length); 312if (numDigitsRead < JsonConstants.DateTimeNumFractionDigits) 323while (numDigitsRead < JsonConstants.DateTimeNumFractionDigits) 343case JsonConstants.UtcOffsetToken: 344parseData.OffsetToken = JsonConstants.UtcOffsetToken; 346case JsonConstants.Plus: 347case JsonConstants.Hyphen: 373|| offsetData[2] != JsonConstants.Colon 408if (((uint)parseData.OffsetHours) > JsonConstants.MaxDateTimeUtcOffsetHours) 420if (parseData.OffsetHours == JsonConstants.MaxDateTimeUtcOffsetHours && parseData.OffsetMinutes != 0) 539Debug.Assert(parseData.Fraction >= 0 && parseData.Fraction <= JsonConstants.MaxDateTimeFraction); // All of our callers to date parse the fraction from fixed 7-digit fields so this value is trusted.
System\Text\Json\JsonHelpers.Escaping.cs (9)
33Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8Value.Length); 40Span<byte> escapedValue = length <= JsonConstants.StackallocByteThreshold ? 41stackalloc byte[JsonConstants.StackallocByteThreshold] : 61Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8Value.Length); 68Span<byte> escapedValue = length <= JsonConstants.StackallocByteThreshold ? 69stackalloc byte[JsonConstants.StackallocByteThreshold] : 89propertySection[0] = JsonConstants.Quote; 91propertySection[++length] = JsonConstants.Quote; 92propertySection[++length] = JsonConstants.KeyValueSeparator;
System\Text\Json\Nodes\JsonArray.cs (1)
252Span<char> chars = stackalloc char[JsonConstants.MaximumFormatUInt32Length];
System\Text\Json\Nodes\JsonNode.cs (1)
143var path = new ValueStringBuilder(stackalloc char[JsonConstants.StackallocCharThreshold]);
System\Text\Json\Reader\JsonReaderHelper.cs (18)
27int lastLineFeedIndex = data.LastIndexOf(JsonConstants.LineFeed); 35newLines += data.Count(JsonConstants.LineFeed); 84Debug.Assert(source.Length <= JsonConstants.MaximumEscapedDateTimeOffsetParseLength); 85Span<byte> sourceUnescaped = stackalloc byte[JsonConstants.MaximumEscapedDateTimeOffsetParseLength]; 106Debug.Assert(source.Length <= JsonConstants.MaximumEscapedDateTimeOffsetParseLength); 107Span<byte> sourceUnescaped = stackalloc byte[JsonConstants.MaximumEscapedDateTimeOffsetParseLength]; 128Debug.Assert(source.Length <= JsonConstants.MaximumEscapedGuidLength); 130Span<byte> utf8Unescaped = stackalloc byte[JsonConstants.MaximumEscapedGuidLength]; 137if (utf8Unescaped.Length == JsonConstants.MaximumFormatGuidLength 153if (span.SequenceEqual(JsonConstants.NaNValue)) 161if (span.SequenceEqual(JsonConstants.PositiveInfinityValue)) 169if (span.SequenceEqual(JsonConstants.NegativeInfinityValue)) 185if (span.SequenceEqual(JsonConstants.NaNValue)) 193if (span.SequenceEqual(JsonConstants.PositiveInfinityValue)) 201if (span.SequenceEqual(JsonConstants.NegativeInfinityValue)) 216if (span.SequenceEqual(JsonConstants.NaNValue)) 224if (span.SequenceEqual(JsonConstants.PositiveInfinityValue)) 232if (span.SequenceEqual(JsonConstants.NegativeInfinityValue))
System\Text\Json\Reader\JsonReaderHelper.Unescaping.cs (52)
18Span<byte> utf8Unescaped = utf8Source.Length <= JsonConstants.StackallocByteThreshold ? 19stackalloc byte[JsonConstants.StackallocByteThreshold] : 48Span<byte> utf8Unescaped = length <= JsonConstants.StackallocByteThreshold ? 49stackalloc byte[JsonConstants.StackallocByteThreshold] : 75Span<byte> utf8Unescaped = length <= JsonConstants.StackallocByteThreshold ? 76stackalloc byte[JsonConstants.StackallocByteThreshold] : 96Debug.Assert(utf8Source.Length >= other.Length && utf8Source.Length / JsonConstants.MaxExpansionFactorWhileEscaping <= other.Length); 100Span<byte> utf8Unescaped = utf8Source.Length <= JsonConstants.StackallocByteThreshold ? 101stackalloc byte[JsonConstants.StackallocByteThreshold] : 124Debug.Assert(utf8Source.Length >= other.Length && utf8Source.Length / JsonConstants.MaxExpansionFactorWhileEscaping <= other.Length); 131Span<byte> utf8Unescaped = length <= JsonConstants.StackallocByteThreshold ? 132stackalloc byte[JsonConstants.StackallocByteThreshold] : 135Span<byte> utf8Escaped = length <= JsonConstants.StackallocByteThreshold ? 136stackalloc byte[JsonConstants.StackallocByteThreshold] : 164int index1 = utf8Source1.IndexOf(JsonConstants.BackSlash); 165int index2 = utf8Source2.IndexOf(JsonConstants.BackSlash); 173Span<byte> utf8Unescaped1 = utf8Source1.Length <= JsonConstants.StackallocByteThreshold ? 174stackalloc byte[JsonConstants.StackallocByteThreshold] : 177Span<byte> utf8Unescaped2 = utf8Source2.Length <= JsonConstants.StackallocByteThreshold ? 178stackalloc byte[JsonConstants.StackallocByteThreshold] : 222Span<byte> byteSpan = utf8Unescaped.Length <= JsonConstants.StackallocByteThreshold ? 223stackalloc byte[JsonConstants.StackallocByteThreshold] : 448int idx = source.IndexOf(JsonConstants.BackSlash); 458Debug.Assert(source[idx] == JsonConstants.BackSlash); 470int idx = source.IndexOf(JsonConstants.BackSlash); 482Debug.Assert(source[idx] == JsonConstants.BackSlash); 494Debug.Assert(source[idx] == JsonConstants.BackSlash); 503case JsonConstants.Quote: 504destination[written++] = JsonConstants.Quote; 507destination[written++] = JsonConstants.LineFeed; 510destination[written++] = JsonConstants.CarriageReturn; 512case JsonConstants.BackSlash: 513destination[written++] = JsonConstants.BackSlash; 515case JsonConstants.Slash: 516destination[written++] = JsonConstants.Slash; 519destination[written++] = JsonConstants.Tab; 522destination[written++] = JsonConstants.BackSpace; 525destination[written++] = JsonConstants.FormFeed; 539if (JsonHelpers.IsInRangeInclusive((uint)scalar, JsonConstants.HighSurrogateStartValue, JsonConstants.LowSurrogateEndValue)) 542if (scalar >= JsonConstants.LowSurrogateStartValue) 547Debug.Assert(JsonHelpers.IsInRangeInclusive((uint)scalar, JsonConstants.HighSurrogateStartValue, JsonConstants.HighSurrogateEndValue)); 563if (!JsonHelpers.IsInRangeInclusive((uint)lowSurrogate, JsonConstants.LowSurrogateStartValue, JsonConstants.LowSurrogateEndValue)) 570scalar = (JsonConstants.BitShiftBy10 * (scalar - JsonConstants.HighSurrogateStartValue)) 571+ (lowSurrogate - JsonConstants.LowSurrogateStartValue) 572+ JsonConstants.UnicodePlane01StartValue; 592if (source[idx] != JsonConstants.BackSlash) 595int nextUnescapedSegmentLength = remaining.IndexOf(JsonConstants.BackSlash); 628Debug.Assert(idx == source.Length || source[idx] == JsonConstants.BackSlash);
System\Text\Json\Reader\Utf8JsonReader.cs (103)
540int length = checked(text.Length * JsonConstants.MaxExpansionFactorWhileTranscoding); 542if (length > JsonConstants.StackallocByteThreshold) 549otherUtf8Text = stackalloc byte[JsonConstants.StackallocByteThreshold]; 615if (localSpan.Length < other.Length || localSpan.Length / JsonConstants.MaxExpansionFactorWhileEscaping > other.Length) 620int idx = localSpan.IndexOf(JsonConstants.BackSlash); 641if (sequenceLength < other.Length || sequenceLength / JsonConstants.MaxExpansionFactorWhileEscaping > other.Length) 654int idx = span.IndexOf(JsonConstants.BackSlash); 719|| sourceLength / (ValueIsEscaped ? JsonConstants.MaxExpansionFactorWhileEscaping : JsonConstants.MaxExpansionFactorWhileTranscoding) > charTextLength) 732|| sourceLength / (ValueIsEscaped ? JsonConstants.MaxExpansionFactorWhileEscaping : JsonConstants.MaxExpansionFactorWhileTranscoding) > charTextLength) 756ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.MismatchedObjectArray, JsonConstants.CloseBrace); 790ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.MismatchedObjectArray, JsonConstants.CloseBracket); 832if (first <= JsonConstants.Space) 849if (first == JsonConstants.Slash) 857if (first == JsonConstants.CloseBrace) 863if (first != JsonConstants.Quote) 885if (first == JsonConstants.CloseBracket) 962if (first == JsonConstants.OpenBrace) 972else if (first == JsonConstants.OpenBracket) 1016if (val is not JsonConstants.Space and 1017not JsonConstants.CarriageReturn and 1018not JsonConstants.LineFeed and 1019not JsonConstants.Tab) 1024if (val == JsonConstants.LineFeed) 1045Debug.Assert((_trailingCommaBeforeComment && marker != JsonConstants.Slash) || !_trailingCommaBeforeComment); 1048if (marker == JsonConstants.Quote) 1052else if (marker == JsonConstants.OpenBrace) 1056else if (marker == JsonConstants.OpenBracket) 1066return ConsumeLiteral(JsonConstants.FalseValue, JsonTokenType.False); 1070return ConsumeLiteral(JsonConstants.TrueValue, JsonTokenType.True); 1074return ConsumeLiteral(JsonConstants.NullValue, JsonTokenType.Null); 1083if (marker == JsonConstants.Slash) 1090if (marker == JsonConstants.Slash) 1106if (marker <= JsonConstants.Space) 1232JsonConstants.Delimiters.IndexOf(_buffer[_consumed]) >= 0) 1257if (first <= JsonConstants.Space) 1268if (first != JsonConstants.KeyValueSeparator) 1282Debug.Assert(_buffer[_consumed] == JsonConstants.Quote); 1296if (foundByte == JsonConstants.Quote) 1327Debug.Assert(data[idx] != JsonConstants.Quote); 1328Debug.Assert(data[idx] == JsonConstants.BackSlash || data[idx] < JsonConstants.Space); 1339if (currentByte == JsonConstants.Quote) 1347else if (currentByte == JsonConstants.BackSlash) 1353int index = JsonConstants.EscapableChars.IndexOf(currentByte); 1377else if (currentByte < JsonConstants.Space) 1573if (JsonConstants.Delimiters.IndexOf(nextByte) >= 0) 1629if (JsonConstants.Delimiters.IndexOf(nextByte) >= 0) 1729if (marker == JsonConstants.Slash) 1755if (marker == JsonConstants.ListSeparator) 1773if (first <= JsonConstants.Space) 1786if (_readerOptions.CommentHandling == JsonCommentHandling.Allow && first == JsonConstants.Slash) 1794if (first != JsonConstants.Quote) 1796if (first == JsonConstants.CloseBrace) 1811if (first == JsonConstants.CloseBracket) 1823else if (marker == JsonConstants.CloseBrace) 1827else if (marker == JsonConstants.CloseBracket) 1862if (first <= JsonConstants.Space) 1882Debug.Assert(first != JsonConstants.Slash); 1886if (first == JsonConstants.ListSeparator) 1910if (first <= JsonConstants.Space) 1923if (first == JsonConstants.Slash) 1938if (first != JsonConstants.Quote) 1940if (first == JsonConstants.CloseBrace) 1963if (first == JsonConstants.CloseBracket) 1983else if (first == JsonConstants.CloseBrace) 1987else if (first == JsonConstants.CloseBracket) 2004Debug.Assert(first != JsonConstants.CloseBrace); 2005if (first != JsonConstants.Quote) 2026Debug.Assert(first != JsonConstants.CloseBracket); 2046Debug.Assert(first != JsonConstants.CloseBrace); 2047if (first != JsonConstants.Quote) 2063Debug.Assert(first != JsonConstants.CloseBracket); 2085while (marker == JsonConstants.Slash) 2097if (marker <= JsonConstants.Space) 2120while (marker == JsonConstants.Slash) 2133if (marker <= JsonConstants.Space) 2166if (marker == JsonConstants.CloseBrace) 2172if (marker != JsonConstants.Quote) 2194if (marker == JsonConstants.CloseBracket) 2224else if (marker == JsonConstants.ListSeparator) 2242if (marker <= JsonConstants.Space) 2262if (marker != JsonConstants.Quote) 2264if (marker == JsonConstants.CloseBrace) 2280if (marker == JsonConstants.CloseBracket) 2293else if (marker == JsonConstants.CloseBrace) 2297else if (marker == JsonConstants.CloseBracket) 2322if (marker == JsonConstants.Slash) 2326else if (marker == JsonConstants.Asterisk) 2332ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.ExpectedStartOfValueNotFound, JsonConstants.Slash); 2338ThrowHelper.ThrowJsonReaderException(ref this, ExceptionResource.ExpectedStartOfValueNotFound, JsonConstants.Slash); 2350if (localBuffer[idx] == JsonConstants.LineFeed) 2356Debug.Assert(localBuffer[idx] == JsonConstants.CarriageReturn); 2360if (localBuffer[idx + 1] == JsonConstants.LineFeed) 2407int idx = localBuffer.IndexOfAny(JsonConstants.LineFeed, JsonConstants.CarriageReturn, JsonConstants.StartingByteOfNonStandardSeparator); 2416if (localBuffer[idx] != JsonConstants.StartingByteOfNonStandardSeparator) 2452int foundIdx = localBuffer.Slice(idx).IndexOf(JsonConstants.Slash); 2461if (foundIdx != 0 && localBuffer[foundIdx + idx - 1] == JsonConstants.Asterisk) 2499if (marker == JsonConstants.Slash) 2503else if (marker == JsonConstants.Asterisk)
System\Text\Json\Reader\Utf8JsonReader.MultiSegment.cs (97)
139if (first <= JsonConstants.Space) 156if (first == JsonConstants.Slash) 164if (first == JsonConstants.CloseBrace) 170if (first != JsonConstants.Quote) 196if (first == JsonConstants.CloseBracket) 337if (first == JsonConstants.OpenBrace) 347else if (first == JsonConstants.OpenBracket) 405Debug.Assert((_trailingCommaBeforeComment && marker != JsonConstants.Slash) || !_trailingCommaBeforeComment); 408if (marker == JsonConstants.Quote) 412else if (marker == JsonConstants.OpenBrace) 416else if (marker == JsonConstants.OpenBracket) 426return ConsumeLiteralMultiSegment(JsonConstants.FalseValue, JsonTokenType.False); 430return ConsumeLiteralMultiSegment(JsonConstants.TrueValue, JsonTokenType.True); 434return ConsumeLiteralMultiSegment(JsonConstants.NullValue, JsonTokenType.Null); 443if (marker == JsonConstants.Slash) 456if (marker == JsonConstants.Slash) 481if (marker <= JsonConstants.Space) 540Debug.Assert(span.Length > 0 && span[0] == literal[0] && literal.Length <= JsonConstants.MaximumLiteralLength); 542Span<byte> readSoFar = stackalloc byte[JsonConstants.MaximumLiteralLength]; 697JsonConstants.Delimiters.IndexOf(_buffer[_consumed]) >= 0) 722if (first <= JsonConstants.Space) 733if (first != JsonConstants.KeyValueSeparator) 747Debug.Assert(_buffer[_consumed] == JsonConstants.Quote); 761if (foundByte == JsonConstants.Quote) 816if (foundByte == JsonConstants.Quote) 837if (currentByte == JsonConstants.Quote) 845else if (currentByte == JsonConstants.BackSlash) 851int index = JsonConstants.EscapableChars.IndexOf(currentByte); 906else if (currentByte < JsonConstants.Space) 956Debug.Assert(data[idx] != JsonConstants.Quote); 957Debug.Assert(data[idx] == JsonConstants.BackSlash || data[idx] < JsonConstants.Space); 974if (currentByte == JsonConstants.Quote) 982else if (currentByte == JsonConstants.BackSlash) 988int index = JsonConstants.EscapableChars.IndexOf(currentByte); 1048else if (currentByte < JsonConstants.Space) 1302if (JsonConstants.Delimiters.IndexOf(nextByte) >= 0) 1331if (JsonConstants.Delimiters.IndexOf(nextByte) >= 0) 1418if (JsonConstants.Delimiters.IndexOf(nextByte) >= 0) 1561if (marker == JsonConstants.Slash) 1587if (marker == JsonConstants.ListSeparator) 1614if (first <= JsonConstants.Space) 1627if (_readerOptions.CommentHandling == JsonCommentHandling.Allow && first == JsonConstants.Slash) 1635if (first != JsonConstants.Quote) 1637if (first == JsonConstants.CloseBrace) 1652if (first == JsonConstants.CloseBracket) 1664else if (marker == JsonConstants.CloseBrace) 1668else if (marker == JsonConstants.CloseBracket) 1703if (first <= JsonConstants.Space) 1723Debug.Assert(first != JsonConstants.Slash); 1727if (first == JsonConstants.ListSeparator) 1760if (first <= JsonConstants.Space) 1773if (first == JsonConstants.Slash) 1788if (first != JsonConstants.Quote) 1790if (first == JsonConstants.CloseBrace) 1813if (first == JsonConstants.CloseBracket) 1833else if (first == JsonConstants.CloseBrace) 1837else if (first == JsonConstants.CloseBracket) 1854Debug.Assert(first != JsonConstants.CloseBrace); 1855if (first != JsonConstants.Quote) 1878Debug.Assert(first != JsonConstants.CloseBracket); 1898Debug.Assert(first != JsonConstants.CloseBrace); 1899if (first != JsonConstants.Quote) 1915Debug.Assert(first != JsonConstants.CloseBracket); 1937while (marker == JsonConstants.Slash) 1949if (marker <= JsonConstants.Space) 1972while (marker == JsonConstants.Slash) 1985if (marker <= JsonConstants.Space) 2018if (marker == JsonConstants.CloseBrace) 2024if (marker != JsonConstants.Quote) 2050if (marker == JsonConstants.CloseBracket) 2080else if (marker == JsonConstants.ListSeparator) 2107if (marker <= JsonConstants.Space) 2127if (marker != JsonConstants.Quote) 2129if (marker == JsonConstants.CloseBrace) 2145if (marker == JsonConstants.CloseBracket) 2157else if (marker == JsonConstants.CloseBrace) 2161else if (marker == JsonConstants.CloseBracket) 2260if (marker != JsonConstants.Slash && marker != JsonConstants.Asterisk) 2265bool multiLine = marker == JsonConstants.Asterisk; 2326if (localBuffer[0] == JsonConstants.LineFeed) 2344if (localBuffer[idx] == JsonConstants.LineFeed) 2350Debug.Assert(localBuffer[idx] == JsonConstants.CarriageReturn); 2354if (localBuffer[idx + 1] == JsonConstants.LineFeed) 2428int idx = localBuffer.IndexOfAny(JsonConstants.LineFeed, JsonConstants.CarriageReturn, JsonConstants.StartingByteOfNonStandardSeparator); 2436if (localBuffer[idx] != JsonConstants.StartingByteOfNonStandardSeparator) 2518if (localBuffer[0] == JsonConstants.Slash) 2530if (localBuffer[0] == JsonConstants.LineFeed) 2539int idx = localBuffer.IndexOfAny(JsonConstants.Asterisk, JsonConstants.LineFeed, JsonConstants.CarriageReturn); 2551case JsonConstants.Asterisk: 2555case JsonConstants.LineFeed: 2560Debug.Assert(marker == JsonConstants.CarriageReturn);
System\Text\Json\Reader\Utf8JsonReader.TryGet.cs (25)
46Debug.Assert(span.IndexOf(JsonConstants.BackSlash) == -1); 156Span<byte> unescapedBuffer = valueLength <= JsonConstants.StackallocByteThreshold ? 157stackalloc byte[JsonConstants.StackallocByteThreshold] : 171Span<byte> intermediate = valueLength <= JsonConstants.StackallocByteThreshold ? 172stackalloc byte[JsonConstants.StackallocByteThreshold] : 208Span<byte> intermediate = sequenceLength <= JsonConstants.StackallocByteThreshold ? 209stackalloc byte[JsonConstants.StackallocByteThreshold] : 841Debug.Assert(span.IndexOf(JsonConstants.BackSlash) == -1); 1251if (!JsonHelpers.IsInRangeInclusive(sequenceLength, JsonConstants.MinimumDateTimeParseLength, JsonConstants.MaximumEscapedDateTimeOffsetParseLength)) 1257Span<byte> stackSpan = stackalloc byte[JsonConstants.MaximumEscapedDateTimeOffsetParseLength]; 1263if (!JsonHelpers.IsInRangeInclusive(ValueSpan.Length, JsonConstants.MinimumDateTimeParseLength, JsonConstants.MaximumEscapedDateTimeOffsetParseLength)) 1277Debug.Assert(span.IndexOf(JsonConstants.BackSlash) == -1); 1316if (!JsonHelpers.IsInRangeInclusive(sequenceLength, JsonConstants.MinimumDateTimeParseLength, JsonConstants.MaximumEscapedDateTimeOffsetParseLength)) 1322Span<byte> stackSpan = stackalloc byte[JsonConstants.MaximumEscapedDateTimeOffsetParseLength]; 1328if (!JsonHelpers.IsInRangeInclusive(ValueSpan.Length, JsonConstants.MinimumDateTimeParseLength, JsonConstants.MaximumEscapedDateTimeOffsetParseLength)) 1342Debug.Assert(span.IndexOf(JsonConstants.BackSlash) == -1); 1382if (sequenceLength > JsonConstants.MaximumEscapedGuidLength) 1388Span<byte> stackSpan = stackalloc byte[JsonConstants.MaximumEscapedGuidLength]; 1394if (ValueSpan.Length > JsonConstants.MaximumEscapedGuidLength) 1408Debug.Assert(span.IndexOf(JsonConstants.BackSlash) == -1); 1410if (span.Length == JsonConstants.MaximumFormatGuidLength
System\Text\Json\Serialization\Converters\Object\ObjectConverterFactory.cs (3)
68if (parameterCount <= JsonConstants.UnboxedParameterCountThreshold) 71Type[] typeArguments = new Type[JsonConstants.UnboxedParameterCountThreshold + 1]; 74for (int i = 0; i < JsonConstants.UnboxedParameterCountThreshold; i++)
System\Text\Json\Serialization\Converters\Value\CharConverter.cs (1)
11private const int MaxEscapedCharacterLength = JsonConstants.MaxExpansionFactorWhileEscaping;
System\Text\Json\Serialization\Converters\Value\DateOnlyConverter.cs (1)
13public const int MaxEscapedFormatLength = FormatLength * JsonConstants.MaxExpansionFactorWhileEscaping;
System\Text\Json\Serialization\Converters\Value\EnumConverter.cs (3)
244Span<char> charBuffer = bufferLength <= JsonConstants.StackallocCharThreshold 245? stackalloc char[JsonConstants.StackallocCharThreshold] 405using ValueStringBuilder sb = new(stackalloc char[JsonConstants.StackallocCharThreshold]);
System\Text\Json\Serialization\Converters\Value\HalfConverter.cs (9)
43Span<byte> byteBuffer = bufferLength <= JsonConstants.StackallocByteThreshold 44? stackalloc byte[JsonConstants.StackallocByteThreshold] 116const byte Quote = JsonConstants.Quote; 150writer.WriteNumberValueAsStringUnescaped(JsonConstants.NaNValue); 154writer.WriteNumberValueAsStringUnescaped(JsonConstants.PositiveInfinityValue); 158writer.WriteNumberValueAsStringUnescaped(JsonConstants.NegativeInfinityValue); 173(!Half.IsNaN(result) || buffer.SequenceEqual(JsonConstants.NaNValue)) && 174(!Half.IsPositiveInfinity(result) || buffer.SequenceEqual(JsonConstants.PositiveInfinityValue)) && 175(!Half.IsNegativeInfinity(result) || buffer.SequenceEqual(JsonConstants.NegativeInfinityValue));
System\Text\Json\Serialization\Converters\Value\Int128Converter.cs (3)
41Span<byte> buffer = bufferLength <= JsonConstants.StackallocByteThreshold 42? stackalloc byte[JsonConstants.StackallocByteThreshold] 94const byte Quote = JsonConstants.Quote;
System\Text\Json\Serialization\Converters\Value\TimeOnlyConverter.cs (1)
15private const int MaximumEscapedTimeOnlyFormatLength = JsonConstants.MaxExpansionFactorWhileEscaping * MaximumTimeOnlyFormatLength;
System\Text\Json\Serialization\Converters\Value\TimeSpanConverter.cs (1)
15private const int MaximumEscapedTimeSpanFormatLength = JsonConstants.MaxExpansionFactorWhileEscaping * MaximumTimeSpanFormatLength;
System\Text\Json\Serialization\Converters\Value\UInt128Converter.cs (3)
41Span<byte> buffer = bufferLength <= JsonConstants.StackallocByteThreshold 42? stackalloc byte[JsonConstants.StackallocByteThreshold] 94const byte Quote = JsonConstants.Quote;
System\Text\Json\Serialization\Converters\Value\VersionConverter.cs (1)
17private const int MaximumEscapedVersionLength = JsonConstants.MaxExpansionFactorWhileEscaping * MaximumVersionLength;
System\Text\Json\Serialization\JsonSerializer.Read.String.cs (12)
389json.Length <= (JsonConstants.StackallocByteThreshold / JsonConstants.MaxExpansionFactorWhileTranscoding) ? stackalloc byte[JsonConstants.StackallocByteThreshold] : 391json.Length <= (JsonConstants.ArrayPoolMaxSizeBeforeUsingNormalAlloc / JsonConstants.MaxExpansionFactorWhileTranscoding) ? tempArray = ArrayPool<byte>.Shared.Rent(json.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) : 420json.Length <= (JsonConstants.StackallocByteThreshold / JsonConstants.MaxExpansionFactorWhileTranscoding) ? stackalloc byte[JsonConstants.StackallocByteThreshold] : 422json.Length <= (JsonConstants.ArrayPoolMaxSizeBeforeUsingNormalAlloc / JsonConstants.MaxExpansionFactorWhileTranscoding) ? tempArray = ArrayPool<byte>.Shared.Rent(json.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) :
System\Text\Json\Serialization\JsonSerializerOptions.cs (2)
98private char _indentCharacter = JsonConstants.DefaultIndentCharacter; 99private int _indentSize = JsonConstants.DefaultIndentSize;
System\Text\Json\Serialization\Metadata\ReflectionEmitMemberAccessor.cs (1)
137Debug.Assert(index <= JsonConstants.UnboxedParameterCountThreshold);
System\Text\Json\Serialization\Metadata\ReflectionMemberAccessor.cs (1)
83Debug.Assert(parameterCount <= JsonConstants.UnboxedParameterCountThreshold);
System\Text\Json\Serialization\ReadBufferState.cs (5)
46_buffer = ArrayPool<byte>.Shared.Rent(Math.Max(initialBufferSize, JsonConstants.Utf8Bom.Length)); 169Debug.Assert(_buffer.Length >= JsonConstants.Utf8Bom.Length); 170if (_buffer.AsSpan(0, _count).StartsWith(JsonConstants.Utf8Bom)) 172_offset = (byte)JsonConstants.Utf8Bom.Length; 173_count -= JsonConstants.Utf8Bom.Length;
System\Text\Json\ThrowHelper.cs (17)
142if (propertyName.Length > JsonConstants.MaxUnescapedTokenSize) 148Debug.Assert(value.Length > JsonConstants.MaxUnescapedTokenSize); 156if (propertyName.Length > JsonConstants.MaxUnescapedTokenSize) 162Debug.Assert(value.Length > JsonConstants.MaxCharacterTokenSize); 170if (propertyName.Length > JsonConstants.MaxCharacterTokenSize) 176Debug.Assert(value.Length > JsonConstants.MaxUnescapedTokenSize); 184if (propertyName.Length > JsonConstants.MaxCharacterTokenSize) 190Debug.Assert(value.Length > JsonConstants.MaxCharacterTokenSize); 198currentDepth &= JsonConstants.RemoveFlagsBitMask; 205Debug.Assert(propertyName.Length > JsonConstants.MaxCharacterTokenSize); 213currentDepth &= JsonConstants.RemoveFlagsBitMask; 237currentDepth &= JsonConstants.RemoveFlagsBitMask; 251currentDepth &= JsonConstants.RemoveFlagsBitMask; 258Debug.Assert(propertyName.Length > JsonConstants.MaxCharacterTokenSize); 615Debug.Assert(token == JsonConstants.CloseBracket || token == JsonConstants.CloseBrace); 621message = SR.Format(SR.DepthTooLarge, currentDepth & JsonConstants.RemoveFlagsBitMask, maxDepth);
System\Text\Json\Writer\JsonWriterHelper.cs (22)
45if (value is not JsonConstants.NewLineLineFeed and not JsonConstants.NewLineCarriageReturnLineFeed) 52if (value is not JsonConstants.DefaultIndentCharacter and not JsonConstants.TabIndentCharacter) 59if (value is < JsonConstants.MinimumIndentSize or > JsonConstants.MaximumIndentSize) 60ThrowHelper.ThrowArgumentOutOfRangeException_IndentSize(nameof(value), JsonConstants.MinimumIndentSize, JsonConstants.MaximumIndentSize); 66if (propertyName.Length > JsonConstants.MaxUnescapedTokenSize) 73if (value.Length > JsonConstants.MaxUnescapedTokenSize) 98if (propertyName.Length > JsonConstants.MaxCharacterTokenSize) 105if (value.Length > JsonConstants.MaxCharacterTokenSize) 112if (propertyName.Length > JsonConstants.MaxCharacterTokenSize || value.Length > JsonConstants.MaxUnescapedTokenSize) 119if (propertyName.Length > JsonConstants.MaxUnescapedTokenSize || value.Length > JsonConstants.MaxCharacterTokenSize) 126if (propertyName.Length > JsonConstants.MaxUnescapedTokenSize || value.Length > JsonConstants.MaxUnescapedTokenSize) 133if (propertyName.Length > JsonConstants.MaxCharacterTokenSize || value.Length > JsonConstants.MaxCharacterTokenSize) 140if (propertyName.Length > JsonConstants.MaxCharacterTokenSize) 147if (propertyName.Length > JsonConstants.MaxUnescapedTokenSize)
System\Text\Json\Writer\JsonWriterHelper.Date.cs (5)
17Span<byte> tempSpan = stackalloc byte[JsonConstants.MaximumFormatDateTimeOffsetLength]; 26Span<byte> tempSpan = stackalloc byte[JsonConstants.MaximumFormatDateTimeOffsetLength]; 45const int maxDateTimeLength = JsonConstants.MaximumFormatDateTimeLength; 53buffer.Length == JsonConstants.MaximumFormatDateTimeOffsetLength); 88else if (buffer.Length == JsonConstants.MaximumFormatDateTimeOffsetLength)
System\Text\Json\Writer\JsonWriterHelper.Escaping.cs (15)
84return firstIndexToEscape + JsonConstants.MaxExpansionFactorWhileEscaping * (textLength - firstIndexToEscape); 164case JsonConstants.Quote: 172case JsonConstants.LineFeed: 175case JsonConstants.CarriageReturn: 178case JsonConstants.Tab: 181case JsonConstants.BackSlash: 184case JsonConstants.BackSpace: 187case JsonConstants.FormFeed: 284case JsonConstants.Quote: 292case JsonConstants.LineFeed: 295case JsonConstants.CarriageReturn: 298case JsonConstants.Tab: 301case JsonConstants.BackSlash: 304case JsonConstants.BackSpace: 307case JsonConstants.FormFeed:
System\Text\Json\Writer\JsonWriterOptions.cs (8)
16private static readonly string s_alternateNewLine = Environment.NewLine.Length == 2 ? JsonConstants.NewLineLineFeed : JsonConstants.NewLineCarriageReturnLineFeed; 55readonly get => (_optionsMask & IndentCharacterBit) != 0 ? JsonConstants.TabIndentCharacter : JsonConstants.DefaultIndentCharacter; 59if (value is not JsonConstants.DefaultIndentCharacter) 850 => JsonConstants.DefaultIndentSize, 86JsonConstants.DefaultIndentSize => 0, 170private const int IndentSizeMask = JsonConstants.MaximumIndentSize << OptionsBitCount;
System\Text\Json\Writer\Utf8JsonWriter.cs (32)
116public int CurrentDepth => _currentDepth & JsonConstants.RemoveFlagsBitMask; 552WriteStart(JsonConstants.OpenBracket); 565WriteStart(JsonConstants.OpenBrace); 585_currentDepth &= JsonConstants.RemoveFlagsBitMask; 599output[BytesPending++] = JsonConstants.ListSeparator; 679output[BytesPending++] = JsonConstants.ListSeparator; 702WriteStartHelper(propertyName.EncodedUtf8Bytes, JsonConstants.OpenBracket); 716WriteStartHelper(propertyName.EncodedUtf8Bytes, JsonConstants.OpenBrace); 722Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 728_currentDepth &= JsonConstants.RemoveFlagsBitMask; 750WriteStartEscape(utf8PropertyName, JsonConstants.OpenBracket); 752_currentDepth &= JsonConstants.RemoveFlagsBitMask; 775WriteStartEscape(utf8PropertyName, JsonConstants.OpenBrace); 777_currentDepth &= JsonConstants.RemoveFlagsBitMask; 814Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 821Span<byte> escapedPropertyName = length <= JsonConstants.StackallocByteThreshold ? 822stackalloc byte[JsonConstants.StackallocByteThreshold] : 899WriteStartEscape(propertyName, JsonConstants.OpenBracket); 901_currentDepth &= JsonConstants.RemoveFlagsBitMask; 924WriteStartEscape(propertyName, JsonConstants.OpenBrace); 926_currentDepth &= JsonConstants.RemoveFlagsBitMask; 963Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 970Span<char> escapedPropertyName = length <= JsonConstants.StackallocCharThreshold ? 971stackalloc char[JsonConstants.StackallocCharThreshold] : 992WriteEnd(JsonConstants.CloseBracket); 1004WriteEnd(JsonConstants.CloseBrace); 1065if (token == JsonConstants.CloseBracket) 1074Debug.Assert(token == JsonConstants.CloseBrace); 1133output[BytesPending++] = JsonConstants.CarriageReturn; 1135output[BytesPending++] = JsonConstants.LineFeed; 1146if (token == JsonConstants.OpenBracket) 1153Debug.Assert(token == JsonConstants.OpenBrace);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Bytes.cs (37)
23Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 136Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 143Span<char> escapedPropertyName = length <= JsonConstants.StackallocCharThreshold ? 144stackalloc char[JsonConstants.StackallocCharThreshold] : 159Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 166Span<byte> escapedPropertyName = length <= JsonConstants.StackallocByteThreshold ? 167stackalloc byte[JsonConstants.StackallocByteThreshold] : 210Debug.Assert(escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding < int.MaxValue - encodedLength - 6); 214int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + encodedLength + 6; 225output[BytesPending++] = JsonConstants.ListSeparator; 227output[BytesPending++] = JsonConstants.Quote; 231output[BytesPending++] = JsonConstants.Quote; 232output[BytesPending++] = JsonConstants.KeyValueSeparator; 234output[BytesPending++] = JsonConstants.Quote; 238output[BytesPending++] = JsonConstants.Quote; 260output[BytesPending++] = JsonConstants.ListSeparator; 262output[BytesPending++] = JsonConstants.Quote; 267output[BytesPending++] = JsonConstants.Quote; 268output[BytesPending++] = JsonConstants.KeyValueSeparator; 270output[BytesPending++] = JsonConstants.Quote; 274output[BytesPending++] = JsonConstants.Quote; 284Debug.Assert(escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding < int.MaxValue - indent - encodedLength - 7 - _newLineLength); 288int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + encodedLength + 7 + _newLineLength; 299output[BytesPending++] = JsonConstants.ListSeparator; 312output[BytesPending++] = JsonConstants.Quote; 316output[BytesPending++] = JsonConstants.Quote; 317output[BytesPending++] = JsonConstants.KeyValueSeparator; 318output[BytesPending++] = JsonConstants.Space; 320output[BytesPending++] = JsonConstants.Quote; 324output[BytesPending++] = JsonConstants.Quote; 349output[BytesPending++] = JsonConstants.ListSeparator; 362output[BytesPending++] = JsonConstants.Quote; 367output[BytesPending++] = JsonConstants.Quote; 368output[BytesPending++] = JsonConstants.KeyValueSeparator; 369output[BytesPending++] = JsonConstants.Space; 371output[BytesPending++] = JsonConstants.Quote; 375output[BytesPending++] = JsonConstants.Quote;
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.DateTime.cs (46)
27Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 143Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 150Span<char> escapedPropertyName = length <= JsonConstants.StackallocCharThreshold ? 151stackalloc char[JsonConstants.StackallocCharThreshold] : 166Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 173Span<byte> escapedPropertyName = length <= JsonConstants.StackallocByteThreshold ? 174stackalloc byte[JsonConstants.StackallocByteThreshold] : 215Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatDateTimeOffsetLength - 6); 219int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDateTimeOffsetLength + 6; 230output[BytesPending++] = JsonConstants.ListSeparator; 232output[BytesPending++] = JsonConstants.Quote; 236output[BytesPending++] = JsonConstants.Quote; 237output[BytesPending++] = JsonConstants.KeyValueSeparator; 239output[BytesPending++] = JsonConstants.Quote; 244output[BytesPending++] = JsonConstants.Quote; 249Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatDateTimeOffsetLength - 6); 251int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatDateTimeOffsetLength + 5; // 2 quotes for property name, 2 quotes for date, and 1 colon 263output[BytesPending++] = JsonConstants.ListSeparator; 265output[BytesPending++] = JsonConstants.Quote; 270output[BytesPending++] = JsonConstants.Quote; 271output[BytesPending++] = JsonConstants.KeyValueSeparator; 273output[BytesPending++] = JsonConstants.Quote; 278output[BytesPending++] = JsonConstants.Quote; 286Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatDateTimeOffsetLength - 7 - _newLineLength); 290int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDateTimeOffsetLength + 7 + _newLineLength; 301output[BytesPending++] = JsonConstants.ListSeparator; 314output[BytesPending++] = JsonConstants.Quote; 318output[BytesPending++] = JsonConstants.Quote; 319output[BytesPending++] = JsonConstants.KeyValueSeparator; 320output[BytesPending++] = JsonConstants.Space; 322output[BytesPending++] = JsonConstants.Quote; 327output[BytesPending++] = JsonConstants.Quote; 335Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatDateTimeOffsetLength - 7 - _newLineLength); 337int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatDateTimeOffsetLength + 6; // 2 quotes for property name, 2 quotes for date, 1 colon, and 1 space 349output[BytesPending++] = JsonConstants.ListSeparator; 362output[BytesPending++] = JsonConstants.Quote; 367output[BytesPending++] = JsonConstants.Quote; 368output[BytesPending++] = JsonConstants.KeyValueSeparator; 369output[BytesPending++] = JsonConstants.Space; 371output[BytesPending++] = JsonConstants.Quote; 376output[BytesPending++] = JsonConstants.Quote; 381Span<byte> buffer = stackalloc byte[JsonConstants.MaximumFormatDateTimeOffsetLength];
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.DateTimeOffset.cs (46)
26Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 142Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 149Span<char> escapedPropertyName = length <= JsonConstants.StackallocCharThreshold ? 150stackalloc char[JsonConstants.StackallocCharThreshold] : 165Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 172Span<byte> escapedPropertyName = length <= JsonConstants.StackallocByteThreshold ? 173stackalloc byte[JsonConstants.StackallocByteThreshold] : 214Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatDateTimeOffsetLength - 6); 218int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDateTimeOffsetLength + 6; 229output[BytesPending++] = JsonConstants.ListSeparator; 231output[BytesPending++] = JsonConstants.Quote; 235output[BytesPending++] = JsonConstants.Quote; 236output[BytesPending++] = JsonConstants.KeyValueSeparator; 238output[BytesPending++] = JsonConstants.Quote; 243output[BytesPending++] = JsonConstants.Quote; 248Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatDateTimeOffsetLength - 6); 250int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatDateTimeOffsetLength + 5; // 2 quotes for property name, 2 quotes for date, and 1 colon 262output[BytesPending++] = JsonConstants.ListSeparator; 264output[BytesPending++] = JsonConstants.Quote; 269output[BytesPending++] = JsonConstants.Quote; 270output[BytesPending++] = JsonConstants.KeyValueSeparator; 272output[BytesPending++] = JsonConstants.Quote; 277output[BytesPending++] = JsonConstants.Quote; 285Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatDateTimeOffsetLength - 7 - _newLineLength); 289int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDateTimeOffsetLength + 7 + _newLineLength; 300output[BytesPending++] = JsonConstants.ListSeparator; 313output[BytesPending++] = JsonConstants.Quote; 317output[BytesPending++] = JsonConstants.Quote; 318output[BytesPending++] = JsonConstants.KeyValueSeparator; 319output[BytesPending++] = JsonConstants.Space; 321output[BytesPending++] = JsonConstants.Quote; 326output[BytesPending++] = JsonConstants.Quote; 334Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatDateTimeOffsetLength - 7 - _newLineLength); 336int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatDateTimeOffsetLength + 6; // 2 quotes for property name, 2 quotes for date, 1 colon, and 1 space 348output[BytesPending++] = JsonConstants.ListSeparator; 361output[BytesPending++] = JsonConstants.Quote; 366output[BytesPending++] = JsonConstants.Quote; 367output[BytesPending++] = JsonConstants.KeyValueSeparator; 368output[BytesPending++] = JsonConstants.Space; 370output[BytesPending++] = JsonConstants.Quote; 375output[BytesPending++] = JsonConstants.Quote; 380Span<byte> buffer = stackalloc byte[JsonConstants.MaximumFormatDateTimeOffsetLength];
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Decimal.cs (38)
26Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 142Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 149Span<char> escapedPropertyName = length <= JsonConstants.StackallocCharThreshold ? 150stackalloc char[JsonConstants.StackallocCharThreshold] : 165Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 172Span<byte> escapedPropertyName = length <= JsonConstants.StackallocByteThreshold ? 173stackalloc byte[JsonConstants.StackallocByteThreshold] : 214Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatDecimalLength - 4); 218int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDecimalLength + 4; 229output[BytesPending++] = JsonConstants.ListSeparator; 231output[BytesPending++] = JsonConstants.Quote; 235output[BytesPending++] = JsonConstants.Quote; 236output[BytesPending++] = JsonConstants.KeyValueSeparator; 245Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatDecimalLength - 4); 247int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatDecimalLength + 3; // 2 quotes for property name, and 1 colon 259output[BytesPending++] = JsonConstants.ListSeparator; 261output[BytesPending++] = JsonConstants.Quote; 266output[BytesPending++] = JsonConstants.Quote; 267output[BytesPending++] = JsonConstants.KeyValueSeparator; 279Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatDecimalLength - 5 - _newLineLength); 283int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDecimalLength + 5 + _newLineLength; 294output[BytesPending++] = JsonConstants.ListSeparator; 307output[BytesPending++] = JsonConstants.Quote; 311output[BytesPending++] = JsonConstants.Quote; 312output[BytesPending++] = JsonConstants.KeyValueSeparator; 313output[BytesPending++] = JsonConstants.Space; 325Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatDecimalLength - 5 - _newLineLength); 327int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatDecimalLength + 4; // 2 quotes for property name, 1 colon, and 1 space 339output[BytesPending++] = JsonConstants.ListSeparator; 352output[BytesPending++] = JsonConstants.Quote; 357output[BytesPending++] = JsonConstants.Quote; 358output[BytesPending++] = JsonConstants.KeyValueSeparator; 359output[BytesPending++] = JsonConstants.Space; 368Span<byte> utf8PropertyName = stackalloc byte[JsonConstants.MaximumFormatDecimalLength];
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Double.cs (38)
26Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 146Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 153Span<char> escapedPropertyName = length <= JsonConstants.StackallocCharThreshold ? 154stackalloc char[JsonConstants.StackallocCharThreshold] : 169Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 176Span<byte> escapedPropertyName = length <= JsonConstants.StackallocByteThreshold ? 177stackalloc byte[JsonConstants.StackallocByteThreshold] : 218Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatDoubleLength - 4); 222int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDoubleLength + 4; 233output[BytesPending++] = JsonConstants.ListSeparator; 235output[BytesPending++] = JsonConstants.Quote; 239output[BytesPending++] = JsonConstants.Quote; 240output[BytesPending++] = JsonConstants.KeyValueSeparator; 249Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatDoubleLength - 4); 251int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatDoubleLength + 3; // 2 quotes for property name, and 1 colon 263output[BytesPending++] = JsonConstants.ListSeparator; 265output[BytesPending++] = JsonConstants.Quote; 270output[BytesPending++] = JsonConstants.Quote; 271output[BytesPending++] = JsonConstants.KeyValueSeparator; 283Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatDoubleLength - 5 - _newLineLength); 287int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDoubleLength + 5 + _newLineLength; 298output[BytesPending++] = JsonConstants.ListSeparator; 311output[BytesPending++] = JsonConstants.Quote; 315output[BytesPending++] = JsonConstants.Quote; 316output[BytesPending++] = JsonConstants.KeyValueSeparator; 317output[BytesPending++] = JsonConstants.Space; 329Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatDoubleLength - 5 - _newLineLength); 331int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatDoubleLength + 4; // 2 quotes for property name, 1 colon, and 1 space 343output[BytesPending++] = JsonConstants.ListSeparator; 356output[BytesPending++] = JsonConstants.Quote; 361output[BytesPending++] = JsonConstants.Quote; 362output[BytesPending++] = JsonConstants.KeyValueSeparator; 363output[BytesPending++] = JsonConstants.Space; 373Span<byte> utf8PropertyName = stackalloc byte[JsonConstants.MaximumFormatDoubleLength];
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Float.cs (38)
26Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 146Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 153Span<char> escapedPropertyName = length <= JsonConstants.StackallocCharThreshold ? 154stackalloc char[JsonConstants.StackallocCharThreshold] : 169Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 176Span<byte> escapedPropertyName = length <= JsonConstants.StackallocByteThreshold ? 177stackalloc byte[JsonConstants.StackallocByteThreshold] : 218Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatSingleLength - 4); 222int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatSingleLength + 4; 233output[BytesPending++] = JsonConstants.ListSeparator; 235output[BytesPending++] = JsonConstants.Quote; 239output[BytesPending++] = JsonConstants.Quote; 240output[BytesPending++] = JsonConstants.KeyValueSeparator; 249Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatSingleLength - 4); 251int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatSingleLength + 3; // 2 quotes for property name, and 1 colon 263output[BytesPending++] = JsonConstants.ListSeparator; 265output[BytesPending++] = JsonConstants.Quote; 270output[BytesPending++] = JsonConstants.Quote; 271output[BytesPending++] = JsonConstants.KeyValueSeparator; 283Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatSingleLength - 5 - _newLineLength); 287int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatSingleLength + 5 + _newLineLength; 298output[BytesPending++] = JsonConstants.ListSeparator; 311output[BytesPending++] = JsonConstants.Quote; 315output[BytesPending++] = JsonConstants.Quote; 316output[BytesPending++] = JsonConstants.KeyValueSeparator; 317output[BytesPending++] = JsonConstants.Space; 329Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatSingleLength - 5 - _newLineLength); 331int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatSingleLength + 4; // 2 quotes for property name, 1 colon, and 1 space 343output[BytesPending++] = JsonConstants.ListSeparator; 356output[BytesPending++] = JsonConstants.Quote; 361output[BytesPending++] = JsonConstants.Quote; 362output[BytesPending++] = JsonConstants.KeyValueSeparator; 363output[BytesPending++] = JsonConstants.Space; 372Span<byte> utf8PropertyName = stackalloc byte[JsonConstants.MaximumFormatSingleLength];
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.FormattedNumber.cs (6)
116Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 123Span<char> escapedPropertyName = length <= JsonConstants.StackallocCharThreshold ? 124stackalloc char[JsonConstants.StackallocCharThreshold] : 139Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 146Span<byte> escapedPropertyName = length <= JsonConstants.StackallocByteThreshold ? 147stackalloc byte[JsonConstants.StackallocByteThreshold] :
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Guid.cs (46)
26Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 142Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 149Span<char> escapedPropertyName = length <= JsonConstants.StackallocCharThreshold ? 150stackalloc char[JsonConstants.StackallocCharThreshold] : 165Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 172Span<byte> escapedPropertyName = length <= JsonConstants.StackallocByteThreshold ? 173stackalloc byte[JsonConstants.StackallocByteThreshold] : 214Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatGuidLength - 6); 218int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatGuidLength + 6; 229output[BytesPending++] = JsonConstants.ListSeparator; 231output[BytesPending++] = JsonConstants.Quote; 235output[BytesPending++] = JsonConstants.Quote; 236output[BytesPending++] = JsonConstants.KeyValueSeparator; 238output[BytesPending++] = JsonConstants.Quote; 244output[BytesPending++] = JsonConstants.Quote; 249Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatGuidLength - 6); 251int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatGuidLength + 5; // 2 quotes for property name, 2 quotes for date, and 1 colon 263output[BytesPending++] = JsonConstants.ListSeparator; 265output[BytesPending++] = JsonConstants.Quote; 270output[BytesPending++] = JsonConstants.Quote; 271output[BytesPending++] = JsonConstants.KeyValueSeparator; 273output[BytesPending++] = JsonConstants.Quote; 279output[BytesPending++] = JsonConstants.Quote; 287Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatGuidLength - 7 - _newLineLength); 291int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatGuidLength + 7 + _newLineLength; 302output[BytesPending++] = JsonConstants.ListSeparator; 315output[BytesPending++] = JsonConstants.Quote; 319output[BytesPending++] = JsonConstants.Quote; 320output[BytesPending++] = JsonConstants.KeyValueSeparator; 321output[BytesPending++] = JsonConstants.Space; 323output[BytesPending++] = JsonConstants.Quote; 329output[BytesPending++] = JsonConstants.Quote; 337Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatGuidLength - 7 - _newLineLength); 339int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatGuidLength + 6; // 2 quotes for property name, 2 quotes for date, 1 colon, and 1 space 351output[BytesPending++] = JsonConstants.ListSeparator; 364output[BytesPending++] = JsonConstants.Quote; 369output[BytesPending++] = JsonConstants.Quote; 370output[BytesPending++] = JsonConstants.KeyValueSeparator; 371output[BytesPending++] = JsonConstants.Space; 373output[BytesPending++] = JsonConstants.Quote; 379output[BytesPending++] = JsonConstants.Quote; 384Span<byte> utf8PropertyName = stackalloc byte[JsonConstants.MaximumFormatGuidLength];
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Helpers.cs (24)
17if (propertyName.Length > JsonConstants.MaxCharacterTokenSize || CurrentDepth >= _options.MaxDepth) 24if (utf8PropertyName.Length > JsonConstants.MaxUnescapedTokenSize || CurrentDepth >= _options.MaxDepth) 91output[BytesPending++] = JsonConstants.ListSeparator; 93output[BytesPending++] = JsonConstants.Quote; 98output[BytesPending++] = JsonConstants.Quote; 99output[BytesPending++] = JsonConstants.KeyValueSeparator; 122output[BytesPending++] = JsonConstants.ListSeparator; 135output[BytesPending++] = JsonConstants.Quote; 140output[BytesPending++] = JsonConstants.Quote; 142output[BytesPending++] = JsonConstants.KeyValueSeparator; 143output[BytesPending++] = JsonConstants.Space; 149Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - 5); 153int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 5; 164output[BytesPending++] = JsonConstants.ListSeparator; 166output[BytesPending++] = JsonConstants.Quote; 170output[BytesPending++] = JsonConstants.Quote; 171output[BytesPending++] = JsonConstants.KeyValueSeparator; 180Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - 6 - _newLineLength); 184int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 6 + _newLineLength; 195output[BytesPending++] = JsonConstants.ListSeparator; 208output[BytesPending++] = JsonConstants.Quote; 212output[BytesPending++] = JsonConstants.Quote; 214output[BytesPending++] = JsonConstants.KeyValueSeparator; 215output[BytesPending++] = JsonConstants.Space;
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Literal.cs (48)
22WriteLiteralHelper(propertyName.EncodedUtf8Bytes, JsonConstants.NullValue); 33WriteLiteralHelper(escapedName, JsonConstants.NullValue); 38Debug.Assert(escapedPropertyNameSection.Length <= JsonConstants.MaxUnescapedTokenSize - 3); 40ReadOnlySpan<byte> span = JsonConstants.NullValue; 51Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 97ReadOnlySpan<byte> span = JsonConstants.NullValue; 122ReadOnlySpan<byte> span = JsonConstants.NullValue; 142WriteLiteralHelper(propertyName.EncodedUtf8Bytes, JsonConstants.TrueValue); 147WriteLiteralHelper(propertyName.EncodedUtf8Bytes, JsonConstants.FalseValue); 193ReadOnlySpan<byte> span = value ? JsonConstants.TrueValue : JsonConstants.FalseValue; 219ReadOnlySpan<byte> span = value ? JsonConstants.TrueValue : JsonConstants.FalseValue; 261Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 268Span<char> escapedPropertyName = length <= JsonConstants.StackallocCharThreshold ? 269stackalloc char[JsonConstants.StackallocCharThreshold] : 284Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 291Span<byte> escapedPropertyName = length <= JsonConstants.StackallocByteThreshold ? 292stackalloc byte[JsonConstants.StackallocByteThreshold] : 333Debug.Assert(value.Length <= JsonConstants.MaxUnescapedTokenSize); 334Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - value.Length - 4); 338int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + value.Length + 4; 349output[BytesPending++] = JsonConstants.ListSeparator; 351output[BytesPending++] = JsonConstants.Quote; 355output[BytesPending++] = JsonConstants.Quote; 356output[BytesPending++] = JsonConstants.KeyValueSeparator; 364Debug.Assert(value.Length <= JsonConstants.MaxUnescapedTokenSize); 379output[BytesPending++] = JsonConstants.ListSeparator; 381output[BytesPending++] = JsonConstants.Quote; 386output[BytesPending++] = JsonConstants.Quote; 387output[BytesPending++] = JsonConstants.KeyValueSeparator; 397Debug.Assert(value.Length <= JsonConstants.MaxUnescapedTokenSize); 411output[BytesPending++] = JsonConstants.ListSeparator; 426Debug.Assert(value.Length <= JsonConstants.MaxUnescapedTokenSize); 427Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - value.Length - 5 - _newLineLength); 431int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + value.Length + 5 + _newLineLength; 442output[BytesPending++] = JsonConstants.ListSeparator; 455output[BytesPending++] = JsonConstants.Quote; 459output[BytesPending++] = JsonConstants.Quote; 460output[BytesPending++] = JsonConstants.KeyValueSeparator; 461output[BytesPending++] = JsonConstants.Space; 472Debug.Assert(value.Length <= JsonConstants.MaxUnescapedTokenSize); 487output[BytesPending++] = JsonConstants.ListSeparator; 500output[BytesPending++] = JsonConstants.Quote; 505output[BytesPending++] = JsonConstants.Quote; 506output[BytesPending++] = JsonConstants.KeyValueSeparator; 507output[BytesPending++] = JsonConstants.Space; 515Span<byte> utf8PropertyName = stackalloc byte[JsonConstants.MaximumFormatBooleanLength];
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.SignedNumber.cs (38)
26Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 215Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 222Span<char> escapedPropertyName = length <= JsonConstants.StackallocCharThreshold ? 223stackalloc char[JsonConstants.StackallocCharThreshold] : 238Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 245Span<byte> escapedPropertyName = length <= JsonConstants.StackallocByteThreshold ? 246stackalloc byte[JsonConstants.StackallocByteThreshold] : 287Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatInt64Length - 4); 291int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatInt64Length + 4; 302output[BytesPending++] = JsonConstants.ListSeparator; 304output[BytesPending++] = JsonConstants.Quote; 308output[BytesPending++] = JsonConstants.Quote; 309output[BytesPending++] = JsonConstants.KeyValueSeparator; 318Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatInt64Length - 4); 320int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatInt64Length + 3; // 2 quotes for property name, and 1 colon 332output[BytesPending++] = JsonConstants.ListSeparator; 334output[BytesPending++] = JsonConstants.Quote; 339output[BytesPending++] = JsonConstants.Quote; 340output[BytesPending++] = JsonConstants.KeyValueSeparator; 352Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatInt64Length - 5 - _newLineLength); 356int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatInt64Length + 5 + _newLineLength; 367output[BytesPending++] = JsonConstants.ListSeparator; 380output[BytesPending++] = JsonConstants.Quote; 384output[BytesPending++] = JsonConstants.Quote; 385output[BytesPending++] = JsonConstants.KeyValueSeparator; 386output[BytesPending++] = JsonConstants.Space; 398Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatInt64Length - 5 - _newLineLength); 400int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatInt64Length + 4; // 2 quotes for property name, 1 colon, and 1 space 412output[BytesPending++] = JsonConstants.ListSeparator; 425output[BytesPending++] = JsonConstants.Quote; 430output[BytesPending++] = JsonConstants.Quote; 431output[BytesPending++] = JsonConstants.KeyValueSeparator; 432output[BytesPending++] = JsonConstants.Space; 444Span<byte> utf8PropertyName = stackalloc byte[JsonConstants.MaximumFormatInt64Length];
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.String.cs (155)
33Debug.Assert(escapedPropertyNameSection.Length <= JsonConstants.MaxUnescapedTokenSize - 3); 37_currentDepth &= JsonConstants.RemoveFlagsBitMask; 45Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 49_currentDepth &= JsonConstants.RemoveFlagsBitMask; 105_currentDepth &= JsonConstants.RemoveFlagsBitMask; 112Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 121if (length > JsonConstants.StackallocCharThreshold) 128escapedPropertyName = stackalloc char[JsonConstants.StackallocCharThreshold]; 158Debug.Assert(escapedPropertyName.Length <= JsonConstants.MaxEscapedTokenSize); 159Debug.Assert(escapedPropertyName.Length < (int.MaxValue - 4) / JsonConstants.MaxExpansionFactorWhileTranscoding); 163int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 4; 174output[BytesPending++] = JsonConstants.ListSeparator; 176output[BytesPending++] = JsonConstants.Quote; 180output[BytesPending++] = JsonConstants.Quote; 181output[BytesPending++] = JsonConstants.KeyValueSeparator; 189Debug.Assert(escapedPropertyName.Length <= JsonConstants.MaxEscapedTokenSize); 190Debug.Assert(escapedPropertyName.Length < (int.MaxValue - 5 - indent - _newLineLength) / JsonConstants.MaxExpansionFactorWhileTranscoding); 194int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 5 + _newLineLength; 205output[BytesPending++] = JsonConstants.ListSeparator; 216output[BytesPending++] = JsonConstants.Quote; 220output[BytesPending++] = JsonConstants.Quote; 221output[BytesPending++] = JsonConstants.KeyValueSeparator; 222output[BytesPending++] = JsonConstants.Space; 254_currentDepth &= JsonConstants.RemoveFlagsBitMask; 264_currentDepth &= JsonConstants.RemoveFlagsBitMask; 271Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 280if (length > JsonConstants.StackallocByteThreshold) 287escapedPropertyName = stackalloc byte[JsonConstants.StackallocByteThreshold]; 319Debug.Assert(escapedPropertyName.Length <= JsonConstants.MaxEscapedTokenSize); 334output[BytesPending++] = JsonConstants.ListSeparator; 336output[BytesPending++] = JsonConstants.Quote; 341output[BytesPending++] = JsonConstants.Quote; 342output[BytesPending++] = JsonConstants.KeyValueSeparator; 349Debug.Assert(escapedPropertyNameSection.Length <= JsonConstants.MaxEscapedTokenSize - 3); 363output[BytesPending++] = JsonConstants.ListSeparator; 377Debug.Assert(escapedPropertyName.Length <= JsonConstants.MaxEscapedTokenSize); 392output[BytesPending++] = JsonConstants.ListSeparator; 405output[BytesPending++] = JsonConstants.Quote; 410output[BytesPending++] = JsonConstants.Quote; 411output[BytesPending++] = JsonConstants.KeyValueSeparator; 412output[BytesPending++] = JsonConstants.Space; 428Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize && utf8Value.Length <= JsonConstants.MaxUnescapedTokenSize); 595Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 682Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 769Debug.Assert(utf8Value.Length <= JsonConstants.MaxUnescapedTokenSize); 841Debug.Assert(utf8Value.Length <= JsonConstants.MaxUnescapedTokenSize); 896Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8Value.Length); 903Span<byte> escapedValue = length <= JsonConstants.StackallocByteThreshold ? 904stackalloc byte[JsonConstants.StackallocByteThreshold] : 919Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= value.Length); 926Span<char> escapedValue = length <= JsonConstants.StackallocCharThreshold ? 927stackalloc char[JsonConstants.StackallocCharThreshold] : 942Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 949Span<char> escapedPropertyName = length <= JsonConstants.StackallocCharThreshold ? 950stackalloc char[JsonConstants.StackallocCharThreshold] : 965Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 972Span<byte> escapedPropertyName = length <= JsonConstants.StackallocByteThreshold ? 973stackalloc byte[JsonConstants.StackallocByteThreshold] : 1064Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= value.Length); 1065Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 1075if (length > JsonConstants.StackallocCharThreshold) 1082escapedValue = stackalloc char[JsonConstants.StackallocCharThreshold]; 1095if (length > JsonConstants.StackallocCharThreshold) 1102escapedPropertyName = stackalloc char[JsonConstants.StackallocCharThreshold]; 1124Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8Value.Length); 1125Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 1135if (length > JsonConstants.StackallocByteThreshold) 1142escapedValue = stackalloc byte[JsonConstants.StackallocByteThreshold]; 1155if (length > JsonConstants.StackallocByteThreshold) 1162escapedPropertyName = stackalloc byte[JsonConstants.StackallocByteThreshold]; 1184Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8Value.Length); 1185Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 1195if (length > JsonConstants.StackallocByteThreshold) 1202escapedValue = stackalloc byte[JsonConstants.StackallocByteThreshold]; 1215if (length > JsonConstants.StackallocCharThreshold) 1222escapedPropertyName = stackalloc char[JsonConstants.StackallocCharThreshold]; 1244Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= value.Length); 1245Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 1255if (length > JsonConstants.StackallocCharThreshold) 1262escapedValue = stackalloc char[JsonConstants.StackallocCharThreshold]; 1275if (length > JsonConstants.StackallocByteThreshold) 1282escapedPropertyName = stackalloc byte[JsonConstants.StackallocByteThreshold]; 1357Debug.Assert(escapedValue.Length <= JsonConstants.MaxUnescapedTokenSize); 1358Debug.Assert(escapedPropertyName.Length < ((int.MaxValue - 6) / JsonConstants.MaxExpansionFactorWhileTranscoding) - escapedValue.Length); 1362int maxRequired = ((escapedPropertyName.Length + escapedValue.Length) * JsonConstants.MaxExpansionFactorWhileTranscoding) + 6; 1373output[BytesPending++] = JsonConstants.ListSeparator; 1375output[BytesPending++] = JsonConstants.Quote; 1379output[BytesPending++] = JsonConstants.Quote; 1380output[BytesPending++] = JsonConstants.KeyValueSeparator; 1382output[BytesPending++] = JsonConstants.Quote; 1386output[BytesPending++] = JsonConstants.Quote; 1392Debug.Assert(escapedValue.Length <= JsonConstants.MaxEscapedTokenSize); 1407output[BytesPending++] = JsonConstants.ListSeparator; 1409output[BytesPending++] = JsonConstants.Quote; 1414output[BytesPending++] = JsonConstants.Quote; 1415output[BytesPending++] = JsonConstants.KeyValueSeparator; 1417output[BytesPending++] = JsonConstants.Quote; 1422output[BytesPending++] = JsonConstants.Quote; 1428Debug.Assert(escapedValue.Length <= JsonConstants.MaxEscapedTokenSize); 1429Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - escapedValue.Length - 6); 1433int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + escapedValue.Length + 6; 1444output[BytesPending++] = JsonConstants.ListSeparator; 1446output[BytesPending++] = JsonConstants.Quote; 1450output[BytesPending++] = JsonConstants.Quote; 1451output[BytesPending++] = JsonConstants.KeyValueSeparator; 1453output[BytesPending++] = JsonConstants.Quote; 1458output[BytesPending++] = JsonConstants.Quote; 1464Debug.Assert(escapedValue.Length <= JsonConstants.MaxEscapedTokenSize); 1465Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - escapedValue.Length - 6); 1469int maxRequired = (escapedValue.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + escapedPropertyName.Length + 6; 1480output[BytesPending++] = JsonConstants.ListSeparator; 1482output[BytesPending++] = JsonConstants.Quote; 1487output[BytesPending++] = JsonConstants.Quote; 1488output[BytesPending++] = JsonConstants.KeyValueSeparator; 1490output[BytesPending++] = JsonConstants.Quote; 1494output[BytesPending++] = JsonConstants.Quote; 1503Debug.Assert(escapedValue.Length <= JsonConstants.MaxEscapedTokenSize); 1504Debug.Assert(escapedPropertyName.Length < ((int.MaxValue - 7 - indent - _newLineLength) / JsonConstants.MaxExpansionFactorWhileTranscoding) - escapedValue.Length); 1508int maxRequired = indent + ((escapedPropertyName.Length + escapedValue.Length) * JsonConstants.MaxExpansionFactorWhileTranscoding) + 7 + _newLineLength; 1519output[BytesPending++] = JsonConstants.ListSeparator; 1532output[BytesPending++] = JsonConstants.Quote; 1536output[BytesPending++] = JsonConstants.Quote; 1537output[BytesPending++] = JsonConstants.KeyValueSeparator; 1538output[BytesPending++] = JsonConstants.Space; 1540output[BytesPending++] = JsonConstants.Quote; 1544output[BytesPending++] = JsonConstants.Quote; 1553Debug.Assert(escapedValue.Length <= JsonConstants.MaxEscapedTokenSize); 1568output[BytesPending++] = JsonConstants.ListSeparator; 1581output[BytesPending++] = JsonConstants.Quote; 1586output[BytesPending++] = JsonConstants.Quote; 1587output[BytesPending++] = JsonConstants.KeyValueSeparator; 1588output[BytesPending++] = JsonConstants.Space; 1590output[BytesPending++] = JsonConstants.Quote; 1595output[BytesPending++] = JsonConstants.Quote; 1604Debug.Assert(escapedValue.Length <= JsonConstants.MaxEscapedTokenSize); 1605Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - escapedValue.Length - 7 - indent - _newLineLength); 1609int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + escapedValue.Length + 7 + _newLineLength; 1620output[BytesPending++] = JsonConstants.ListSeparator; 1633output[BytesPending++] = JsonConstants.Quote; 1637output[BytesPending++] = JsonConstants.Quote; 1638output[BytesPending++] = JsonConstants.KeyValueSeparator; 1639output[BytesPending++] = JsonConstants.Space; 1641output[BytesPending++] = JsonConstants.Quote; 1646output[BytesPending++] = JsonConstants.Quote; 1655Debug.Assert(escapedValue.Length <= JsonConstants.MaxEscapedTokenSize); 1656Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - escapedValue.Length - 7 - indent - _newLineLength); 1660int maxRequired = indent + (escapedValue.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + escapedPropertyName.Length + 7 + _newLineLength; 1671output[BytesPending++] = JsonConstants.ListSeparator; 1684output[BytesPending++] = JsonConstants.Quote; 1689output[BytesPending++] = JsonConstants.Quote; 1690output[BytesPending++] = JsonConstants.KeyValueSeparator; 1691output[BytesPending++] = JsonConstants.Space; 1693output[BytesPending++] = JsonConstants.Quote; 1697output[BytesPending++] = JsonConstants.Quote;
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.UnsignedNumber.cs (38)
27Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 224Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 231Span<char> escapedPropertyName = length <= JsonConstants.StackallocCharThreshold ? 232stackalloc char[JsonConstants.StackallocCharThreshold] : 247Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 254Span<byte> escapedPropertyName = length <= JsonConstants.StackallocByteThreshold ? 255stackalloc byte[JsonConstants.StackallocByteThreshold] : 296Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatUInt64Length - 4); 300int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatUInt64Length + 4; 311output[BytesPending++] = JsonConstants.ListSeparator; 313output[BytesPending++] = JsonConstants.Quote; 317output[BytesPending++] = JsonConstants.Quote; 318output[BytesPending++] = JsonConstants.KeyValueSeparator; 327Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatUInt64Length - 4); 329int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatUInt64Length + 3; // 2 quotes for property name, and 1 colon 341output[BytesPending++] = JsonConstants.ListSeparator; 343output[BytesPending++] = JsonConstants.Quote; 348output[BytesPending++] = JsonConstants.Quote; 349output[BytesPending++] = JsonConstants.KeyValueSeparator; 361Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatUInt64Length - 5 - _newLineLength); 365int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatUInt64Length + 5 + _newLineLength; 376output[BytesPending++] = JsonConstants.ListSeparator; 389output[BytesPending++] = JsonConstants.Quote; 393output[BytesPending++] = JsonConstants.Quote; 394output[BytesPending++] = JsonConstants.KeyValueSeparator; 395output[BytesPending++] = JsonConstants.Space; 407Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatUInt64Length - 5 - _newLineLength); 409int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatUInt64Length + 4; // 2 quotes for property name, 1 colon, and 1 space 421output[BytesPending++] = JsonConstants.ListSeparator; 434output[BytesPending++] = JsonConstants.Quote; 439output[BytesPending++] = JsonConstants.Quote; 440output[BytesPending++] = JsonConstants.KeyValueSeparator; 441output[BytesPending++] = JsonConstants.Space; 453Span<byte> utf8PropertyName = stackalloc byte[JsonConstants.MaximumFormatUInt64Length];
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.Bytes.cs (6)
78output[BytesPending++] = JsonConstants.ListSeparator; 80output[BytesPending++] = JsonConstants.Quote; 84output[BytesPending++] = JsonConstants.Quote; 118output[BytesPending++] = JsonConstants.ListSeparator; 131output[BytesPending++] = JsonConstants.Quote; 135output[BytesPending++] = JsonConstants.Quote;
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.Comment.cs (20)
80Debug.Assert(value.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - 4); 84int maxRequired = (value.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 4; 93output[BytesPending++] = JsonConstants.Slash; 94output[BytesPending++] = JsonConstants.Asterisk; 105output[BytesPending++] = JsonConstants.Asterisk; 106output[BytesPending++] = JsonConstants.Slash; 114Debug.Assert(value.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - 4 - _newLineLength); 118int maxRequired = indent + (value.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 4 + _newLineLength; 134output[BytesPending++] = JsonConstants.Slash; 135output[BytesPending++] = JsonConstants.Asterisk; 146output[BytesPending++] = JsonConstants.Asterisk; 147output[BytesPending++] = JsonConstants.Slash; 206output[BytesPending++] = JsonConstants.Slash; 207output[BytesPending++] = JsonConstants.Asterisk; 212output[BytesPending++] = JsonConstants.Asterisk; 213output[BytesPending++] = JsonConstants.Slash; 241output[BytesPending++] = JsonConstants.Slash; 242output[BytesPending++] = JsonConstants.Asterisk; 247output[BytesPending++] = JsonConstants.Asterisk; 248output[BytesPending++] = JsonConstants.Slash;
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.DateTime.cs (8)
44int maxRequired = JsonConstants.MaximumFormatDateTimeOffsetLength + 3; // 2 quotes, and optionally, 1 list separator 55output[BytesPending++] = JsonConstants.ListSeparator; 58output[BytesPending++] = JsonConstants.Quote; 63output[BytesPending++] = JsonConstants.Quote; 72int maxRequired = indent + JsonConstants.MaximumFormatDateTimeOffsetLength + 3 + _newLineLength; 83output[BytesPending++] = JsonConstants.ListSeparator; 96output[BytesPending++] = JsonConstants.Quote; 101output[BytesPending++] = JsonConstants.Quote;
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.DateTimeOffset.cs (8)
45int maxRequired = JsonConstants.MaximumFormatDateTimeOffsetLength + 3; // 2 quotes, and optionally, 1 list separator 56output[BytesPending++] = JsonConstants.ListSeparator; 59output[BytesPending++] = JsonConstants.Quote; 64output[BytesPending++] = JsonConstants.Quote; 73int maxRequired = indent + JsonConstants.MaximumFormatDateTimeOffsetLength + 3 + _newLineLength; 84output[BytesPending++] = JsonConstants.ListSeparator; 97output[BytesPending++] = JsonConstants.Quote; 102output[BytesPending++] = JsonConstants.Quote;
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.Decimal.cs (5)
44int maxRequired = JsonConstants.MaximumFormatDecimalLength + 1; // Optionally, 1 list separator 55output[BytesPending++] = JsonConstants.ListSeparator; 68int maxRequired = indent + JsonConstants.MaximumFormatDecimalLength + 1 + _newLineLength; // Optionally, 1 list separator and 1-2 bytes for new line 79output[BytesPending++] = JsonConstants.ListSeparator; 99Span<byte> utf8Number = stackalloc byte[JsonConstants.MaximumFormatDecimalLength];
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.Double.cs (8)
48int maxRequired = JsonConstants.MaximumFormatDoubleLength + 1; // Optionally, 1 list separator 59output[BytesPending++] = JsonConstants.ListSeparator; 72int maxRequired = indent + JsonConstants.MaximumFormatDoubleLength + 1 + _newLineLength; // Optionally, 1 list separator and 1-2 bytes for new line 83output[BytesPending++] = JsonConstants.ListSeparator; 147Span<byte> utf8Number = stackalloc byte[JsonConstants.MaximumFormatDoubleLength]; 157WriteNumberValueAsStringUnescaped(JsonConstants.NaNValue); 161WriteNumberValueAsStringUnescaped(JsonConstants.PositiveInfinityValue); 165WriteNumberValueAsStringUnescaped(JsonConstants.NegativeInfinityValue);
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.Float.cs (8)
48int maxRequired = JsonConstants.MaximumFormatSingleLength + 1; // Optionally, 1 list separator 59output[BytesPending++] = JsonConstants.ListSeparator; 72int maxRequired = indent + JsonConstants.MaximumFormatSingleLength + 1 + _newLineLength; // Optionally, 1 list separator and 1-2 bytes for new line 83output[BytesPending++] = JsonConstants.ListSeparator; 147Span<byte> utf8Number = stackalloc byte[JsonConstants.MaximumFormatSingleLength]; 157WriteNumberValueAsStringUnescaped(JsonConstants.NaNValue); 161WriteNumberValueAsStringUnescaped(JsonConstants.PositiveInfinityValue); 165WriteNumberValueAsStringUnescaped(JsonConstants.NegativeInfinityValue);
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.FormattedNumber.cs (2)
60output[BytesPending++] = JsonConstants.ListSeparator; 85output[BytesPending++] = JsonConstants.ListSeparator;
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.Guid.cs (8)
44int maxRequired = JsonConstants.MaximumFormatGuidLength + 3; // 2 quotes, and optionally, 1 list separator 55output[BytesPending++] = JsonConstants.ListSeparator; 58output[BytesPending++] = JsonConstants.Quote; 64output[BytesPending++] = JsonConstants.Quote; 73int maxRequired = indent + JsonConstants.MaximumFormatGuidLength + 3 + _newLineLength; 84output[BytesPending++] = JsonConstants.ListSeparator; 97output[BytesPending++] = JsonConstants.Quote; 103output[BytesPending++] = JsonConstants.Quote;
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.Literal.cs (5)
18WriteLiteralByOptions(JsonConstants.NullValue); 35WriteLiteralByOptions(JsonConstants.TrueValue); 40WriteLiteralByOptions(JsonConstants.FalseValue); 79output[BytesPending++] = JsonConstants.ListSeparator; 103output[BytesPending++] = JsonConstants.ListSeparator;
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.Raw.cs (9)
184output[BytesPending++] = JsonConstants.ListSeparator; 195if (json.Length > JsonConstants.MaxUtf16RawValueLength) 205json.Length <= (JsonConstants.StackallocByteThreshold / JsonConstants.MaxExpansionFactorWhileTranscoding) ? stackalloc byte[JsonConstants.StackallocByteThreshold] : 207json.Length <= (JsonConstants.ArrayPoolMaxSizeBeforeUsingNormalAlloc / JsonConstants.MaxExpansionFactorWhileTranscoding) ? tempArray = ArrayPool<byte>.Shared.Rent(json.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) : 272output[BytesPending++] = JsonConstants.ListSeparator;
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.SignedNumber.cs (5)
57int maxRequired = JsonConstants.MaximumFormatInt64Length + 1; // Optionally, 1 list separator 68output[BytesPending++] = JsonConstants.ListSeparator; 81int maxRequired = indent + JsonConstants.MaximumFormatInt64Length + 1 + _newLineLength; // Optionally, 1 list separator and 1-2 bytes for new line 92output[BytesPending++] = JsonConstants.ListSeparator; 112Span<byte> utf8Number = stackalloc byte[JsonConstants.MaximumFormatInt64Length];
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.String.cs (23)
21Debug.Assert(utf8Value.Length <= JsonConstants.MaxUnescapedTokenSize); 118Debug.Assert(escapedValue.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - 3); 122int maxRequired = (escapedValue.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 3; 133output[BytesPending++] = JsonConstants.ListSeparator; 135output[BytesPending++] = JsonConstants.Quote; 139output[BytesPending++] = JsonConstants.Quote; 148Debug.Assert(escapedValue.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - 3 - _newLineLength); 152int maxRequired = indent + (escapedValue.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 3 + _newLineLength; 163output[BytesPending++] = JsonConstants.ListSeparator; 176output[BytesPending++] = JsonConstants.Quote; 180output[BytesPending++] = JsonConstants.Quote; 185Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= value.Length); 192Span<char> escapedValue = length <= JsonConstants.StackallocCharThreshold ? 193stackalloc char[JsonConstants.StackallocCharThreshold] : 279output[BytesPending++] = JsonConstants.ListSeparator; 281output[BytesPending++] = JsonConstants.Quote; 286output[BytesPending++] = JsonConstants.Quote; 309output[BytesPending++] = JsonConstants.ListSeparator; 322output[BytesPending++] = JsonConstants.Quote; 327output[BytesPending++] = JsonConstants.Quote; 332Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8Value.Length); 339Span<byte> escapedValue = length <= JsonConstants.StackallocByteThreshold ? 340stackalloc byte[JsonConstants.StackallocByteThreshold] :
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.StringSegment.cs (13)
135Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= value.Length); 142Span<char> escapedValue = length <= JsonConstants.StackallocCharThreshold ? 143stackalloc char[JsonConstants.StackallocCharThreshold] : 166Debug.Assert(escapedValue.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding)); 168int requiredBytes = escapedValue.Length * JsonConstants.MaxExpansionFactorWhileTranscoding; 304Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8Value.Length); 308Span<byte> escapedValue = length <= JsonConstants.StackallocByteThreshold ? 309stackalloc byte[JsonConstants.StackallocByteThreshold] : 489output[BytesPending++] = JsonConstants.ListSeparator; 502output[BytesPending++] = JsonConstants.Quote; 518output[BytesPending++] = JsonConstants.ListSeparator; 521output[BytesPending++] = JsonConstants.Quote; 531_memory.Span[BytesPending++] = JsonConstants.Quote;
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.UnsignedNumber.cs (5)
59int maxRequired = JsonConstants.MaximumFormatUInt64Length + 1; // Optionally, 1 list separator 70output[BytesPending++] = JsonConstants.ListSeparator; 83int maxRequired = indent + JsonConstants.MaximumFormatUInt64Length + 1 + _newLineLength; // Optionally, 1 list separator and 1-2 bytes for new line 94output[BytesPending++] = JsonConstants.ListSeparator; 114Span<byte> utf8Number = stackalloc byte[JsonConstants.MaximumFormatUInt64Length];