< Summary

Information
Line coverage
100%
Covered lines: 25
Uncovered lines: 0
Coverable lines: 25
Total lines: 87
Line coverage: 100%
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

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
.ctor(...)100%11100%

File(s)

C:\h\w\B31A098C\w\BB5A0A33\e\runtime-utils\Runner\runtime\src\libraries\System.Text.Json\src\System\Text\Json\Reader\JsonReaderState.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    /// <summary>
 7    /// Defines an opaque type that holds and saves all the relevant state information which must be provided
 8    /// to the <see cref="Utf8JsonReader"/> to continue reading after processing incomplete data.
 9    /// This type is required to support reentrancy when reading incomplete data, and to continue
 10    /// reading once more data is available. Unlike the <see cref="Utf8JsonReader"/>, which is a ref struct,
 11    /// this type can survive across async/await boundaries and hence this type is required to provide
 12    /// support for reading in more data asynchronously before continuing with a new instance of the <see cref="Utf8Json
 13    /// </summary>
 14    public readonly struct JsonReaderState
 15    {
 16        internal readonly long _lineNumber;
 17        internal readonly long _bytePositionInLine;
 18        internal readonly bool _inObject;
 19        internal readonly bool _isNotPrimitive;
 20        internal readonly bool _valueIsEscaped;
 21        internal readonly bool _trailingCommaBeforeComment;
 22        internal readonly JsonTokenType _tokenType;
 23        internal readonly JsonTokenType _previousTokenType;
 24        internal readonly JsonReaderOptions _readerOptions;
 25        internal readonly BitStack _bitStack;
 26
 27        /// <summary>
 28        /// Constructs a new <see cref="JsonReaderState"/> instance.
 29        /// </summary>
 30        /// <param name="options">Defines the customized behavior of the <see cref="Utf8JsonReader"/>
 31        /// that is different from the JSON RFC (for example how to handle comments or maximum depth allowed when readin
 32        /// By default, the <see cref="Utf8JsonReader"/> follows the JSON RFC strictly (i.e. comments within the JSON ar
 33        /// <remarks>
 34        /// An instance of this state must be passed to the <see cref="Utf8JsonReader"/> ctor with the JSON data.
 35        /// Unlike the <see cref="Utf8JsonReader"/>, which is a ref struct, the state can survive
 36        /// across async/await boundaries and hence this type is required to provide support for reading
 37        /// in more data asynchronously before continuing with a new instance of the <see cref="Utf8JsonReader"/>.
 38        /// </remarks>
 39        public JsonReaderState(JsonReaderOptions options = default)
 5735240        {
 5735241            _lineNumber = default;
 5735242            _bytePositionInLine = default;
 5735243            _inObject = default;
 5735244            _isNotPrimitive = default;
 5735245            _valueIsEscaped = default;
 5735246            _trailingCommaBeforeComment = default;
 5735247            _tokenType = default;
 5735248            _previousTokenType = default;
 5735249            _readerOptions = options;
 50
 51            // Only allocate if the user reads a JSON payload beyond the depth that the _allocationFreeContainer can han
 52            // This way we avoid allocations in the common, default cases, and allocate lazily.
 5735253            _bitStack = default;
 5735254        }
 55
 56        internal JsonReaderState(
 57            long lineNumber,
 58            long bytePositionInLine,
 59            bool inObject,
 60            bool isNotPrimitive,
 61            bool valueIsEscaped,
 62            bool trailingCommaBeforeComment,
 63            JsonTokenType tokenType,
 64            JsonTokenType previousTokenType,
 65            JsonReaderOptions readerOptions,
 66            BitStack bitStack)
 11696867        {
 11696868            _lineNumber = lineNumber;
 11696869            _bytePositionInLine = bytePositionInLine;
 11696870            _inObject = inObject;
 11696871            _isNotPrimitive = isNotPrimitive;
 11696872            _valueIsEscaped = valueIsEscaped;
 11696873            _trailingCommaBeforeComment = trailingCommaBeforeComment;
 11696874            _tokenType = tokenType;
 11696875            _previousTokenType = previousTokenType;
 11696876            _readerOptions = readerOptions;
 11696877            _bitStack = bitStack;
 11696878        }
 79
 80        /// <summary>
 81        /// Gets the custom behavior when reading JSON using
 82        /// the <see cref="Utf8JsonReader"/> that may deviate from strict adherence
 83        /// to the JSON specification, which is the default behavior.
 84        /// </summary>
 404285        public JsonReaderOptions Options => _readerOptions;
 86    }
 87}