< Summary

Information
Class: System.Text.Json.JsonReaderState
Assembly: System.Text.Json
File(s): D:\runner\runtime\src\libraries\System.Text.Json\src\System\Text\Json\Reader\JsonReaderState.cs
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)

D:\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)
 488440        {
 488441            _lineNumber = default;
 488442            _bytePositionInLine = default;
 488443            _inObject = default;
 488444            _isNotPrimitive = default;
 488445            _valueIsEscaped = default;
 488446            _trailingCommaBeforeComment = default;
 488447            _tokenType = default;
 488448            _previousTokenType = default;
 488449            _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.
 488453            _bitStack = default;
 488454        }
 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)
 950567        {
 950568            _lineNumber = lineNumber;
 950569            _bytePositionInLine = bytePositionInLine;
 950570            _inObject = inObject;
 950571            _isNotPrimitive = isNotPrimitive;
 950572            _valueIsEscaped = valueIsEscaped;
 950573            _trailingCommaBeforeComment = trailingCommaBeforeComment;
 950574            _tokenType = tokenType;
 950575            _previousTokenType = previousTokenType;
 950576            _readerOptions = readerOptions;
 950577            _bitStack = bitStack;
 950578        }
 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>
 3785        public JsonReaderOptions Options => _readerOptions;
 86    }
 87}