< Summary

Information
Line coverage
88%
Covered lines: 8
Uncovered lines: 1
Coverable lines: 9
Total lines: 130
Line coverage: 88.8%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

C:\h\w\B31A098C\w\BB5A0A33\e\runtime-utils\Runner\runtime\src\libraries\System.Text.Json\src\System\Text\Json\JsonConstants.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4namespace System.Text.Json
 5{
 6    internal static partial class JsonConstants
 7    {
 8        public const byte OpenBrace = (byte)'{';
 9        public const byte CloseBrace = (byte)'}';
 10        public const byte OpenBracket = (byte)'[';
 11        public const byte CloseBracket = (byte)']';
 12        public const byte Space = (byte)' ';
 13        public const byte CarriageReturn = (byte)'\r';
 14        public const byte LineFeed = (byte)'\n';
 15        public const byte Tab = (byte)'\t';
 16        public const byte ListSeparator = (byte)',';
 17        public const byte KeyValueSeparator = (byte)':';
 18        public const byte Quote = (byte)'"';
 19        public const byte BackSlash = (byte)'\\';
 20        public const byte Slash = (byte)'/';
 21        public const byte BackSpace = (byte)'\b';
 22        public const byte FormFeed = (byte)'\f';
 23        public const byte Asterisk = (byte)'*';
 24        public const byte Colon = (byte)':';
 25        public const byte Period = (byte)'.';
 26        public const byte Plus = (byte)'+';
 27        public const byte Hyphen = (byte)'-';
 28        public const byte UtcOffsetToken = (byte)'Z';
 29        public const byte TimePrefix = (byte)'T';
 30
 31        public const string NewLineLineFeed = "\n";
 32        public const string NewLineCarriageReturnLineFeed = "\r\n";
 33
 34        // \u2028 and \u2029 are considered respectively line and paragraph separators
 35        // UTF-8 representation for them is E2, 80, A8/A9
 36        public const byte StartingByteOfNonStandardSeparator = 0xE2;
 37
 27781638        public static ReadOnlySpan<byte> Utf8Bom => [0xEF, 0xBB, 0xBF];
 25239        public static ReadOnlySpan<byte> TrueValue => "true"u8;
 42040        public static ReadOnlySpan<byte> FalseValue => "false"u8;
 33641        public static ReadOnlySpan<byte> NullValue => "null"u8;
 42
 4843        public static ReadOnlySpan<byte> NaNValue => "NaN"u8;
 8844        public static ReadOnlySpan<byte> PositiveInfinityValue => "Infinity"u8;
 645        public static ReadOnlySpan<byte> NegativeInfinityValue => "-Infinity"u8;
 46        public const int MaximumFloatingPointConstantLength = 9;
 47
 48        // Used to search for the end of a number
 792049        public static ReadOnlySpan<byte> Delimiters => ",}] \n\r\t/"u8;
 50
 51        // Explicitly skipping ReverseSolidus since that is handled separately
 052        public static ReadOnlySpan<byte> EscapableChars => "\"nrt/ubf"u8;
 53
 54        public const int RemoveFlagsBitMask = 0x7FFFFFFF;
 55
 56        // In the worst case, an ASCII character represented as a single utf-8 byte could expand 6x when escaped.
 57        // For example: '+' becomes '\u0043'
 58        // Escaping surrogate pairs (represented by 3 or 4 utf-8 bytes) would expand to 12 bytes (which is still <= 6x).
 59        // The same factor applies to utf-16 characters.
 60        public const int MaxExpansionFactorWhileEscaping = 6;
 61
 62        // In the worst case, a single UTF-16 character could be expanded to 3 UTF-8 bytes.
 63        // Only surrogate pairs expand to 4 UTF-8 bytes but that is a transformation of 2 UTF-16 characters going to 4 U
 64        // All other UTF-16 characters can be represented by either 1 or 2 UTF-8 bytes.
 65        public const int MaxExpansionFactorWhileTranscoding = 3;
 66
 67        // When transcoding from UTF8 -> UTF16, the byte count threshold where we rent from the array pool before perfor
 68        public const long ArrayPoolMaxSizeBeforeUsingNormalAlloc =
 69#if NET
 70            1024 * 1024 * 1024; // ArrayPool limit increased in .NET 6
 71#else
 72            1024 * 1024;
 73#endif
 74
 75        // The maximum number of characters allowed when writing raw UTF-16 JSON. This is the maximum length that we can
 76        // be safely transcoded to UTF-8 and fit within an integer-length span, given the max expansion factor of a sing
 77        public const int MaxUtf16RawValueLength = int.MaxValue / MaxExpansionFactorWhileTranscoding;
 78
 79        public const int MaxEscapedTokenSize = 1_000_000_000;   // Max size for already escaped value.
 80        public const int MaxUnescapedTokenSize = MaxEscapedTokenSize / MaxExpansionFactorWhileEscaping;  // 166_666_666 
 81        public const int MaxCharacterTokenSize = MaxEscapedTokenSize / MaxExpansionFactorWhileEscaping; // 166_666_666 c
 82
 83        public const int MaximumFormatBooleanLength = 5;
 84        public const int MaximumFormatInt64Length = 20;   // 19 + sign (i.e. -9223372036854775808)
 85        public const int MaximumFormatUInt32Length = 10;  // i.e. 4294967295
 86        public const int MaximumFormatUInt64Length = 20;  // i.e. 18446744073709551615
 87        public const int MaximumFormatDoubleLength = 128;  // default (i.e. 'G'), using 128 (rather than say 32) to be f
 88        public const int MaximumFormatSingleLength = 128;  // default (i.e. 'G'), using 128 (rather than say 32) to be f
 89        public const int MaximumFormatDecimalLength = 31; // default (i.e. 'G')
 90        public const int MaximumFormatGuidLength = 36;    // default (i.e. 'D'), 8 + 4 + 4 + 4 + 12 + 4 for the hyphens 
 91        public const int MaximumEscapedGuidLength = MaxExpansionFactorWhileEscaping * MaximumFormatGuidLength;
 92        public const int MaximumFormatDateTimeLength = 27;    // StandardFormat 'O', e.g. 2017-06-12T05:30:45.7680000
 93        public const int MaximumFormatDateTimeOffsetLength = 33;  // StandardFormat 'O', e.g. 2017-06-12T05:30:45.768000
 94        public const int MaxDateTimeUtcOffsetHours = 14; // The UTC offset portion of a TimeSpan or DateTime can be no m
 95        public const int DateTimeNumFractionDigits = 7;  // TimeSpan and DateTime formats allow exactly up to many digit
 96        public const int MaxDateTimeFraction = 9_999_999;  // The largest fraction expressible by TimeSpan and DateTime 
 97        public const int DateTimeParseNumFractionDigits = 16; // The maximum number of fraction digits the Json DateTime
 98        public const int MaximumDateTimeOffsetParseLength = (MaximumFormatDateTimeOffsetLength +
 99            (DateTimeParseNumFractionDigits - DateTimeNumFractionDigits)); // Like StandardFormat 'O' for DateTimeOffset
 100        public const int MinimumDateTimeParseLength = 10; // YYYY-MM-DD
 101        public const int MaximumEscapedDateTimeOffsetParseLength = MaxExpansionFactorWhileEscaping * MaximumDateTimeOffs
 102
 103        public const int MaximumLiteralLength = 5; // Must be able to fit null, true, & false.
 104
 105        // Encoding Helpers
 106        public const char HighSurrogateStart = '\ud800';
 107        public const char HighSurrogateEnd = '\udbff';
 108        public const char LowSurrogateStart = '\udc00';
 109        public const char LowSurrogateEnd = '\udfff';
 110
 111        public const int UnicodePlane01StartValue = 0x10000;
 112        public const int HighSurrogateStartValue = 0xD800;
 113        public const int HighSurrogateEndValue = 0xDBFF;
 114        public const int LowSurrogateStartValue = 0xDC00;
 115        public const int LowSurrogateEndValue = 0xDFFF;
 116        public const int BitShiftBy10 = 0x400;
 117
 118        // The maximum number of parameters a constructor can have where it can be considered
 119        // for a path on deserialization where we don't box the constructor arguments.
 120        public const int UnboxedParameterCountThreshold = 4;
 121
 122        // Two space characters is the default indentation.
 123        public const char DefaultIndentCharacter = ' ';
 124        public const char TabIndentCharacter = '\t';
 125        public const int DefaultIndentSize = 2;
 126        public const int MinimumIndentSize = 0;
 127        public const int MaximumIndentSize = 127; // If this value is changed, the impact on the options masking used in
 128
 129    }
 130}