< Summary

Line coverage
76%
Covered lines: 13
Uncovered lines: 4
Coverable lines: 17
Total lines: 84
Line coverage: 76.4%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderOptions.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
 4using System.Diagnostics;
 5
 6namespace System.Text.Json
 7{
 8    /// <summary>
 9    /// Provides the ability for the user to define custom behavior when reading JSON.
 10    /// </summary>
 11    public struct JsonReaderOptions
 12    {
 13        internal const int DefaultMaxDepth = 64;
 14
 15        private int _maxDepth;
 16        private JsonCommentHandling _commentHandling;
 17
 18        /// <summary>
 19        /// Defines how the <see cref="Utf8JsonReader"/> should handle comments when reading through the JSON.
 20        /// </summary>
 21        /// <exception cref="ArgumentOutOfRangeException">
 22        /// Thrown when the comment handling enum is set to a value that is not supported (i.e. not within the <see cref
 23        /// </exception>
 24        /// <remarks>
 25        /// By default <exception cref="JsonException"/> is thrown if a comment is encountered.
 26        /// </remarks>
 27        public JsonCommentHandling CommentHandling
 28        {
 24104329            readonly get => _commentHandling;
 30            set
 552231            {
 552232                Debug.Assert(value >= 0);
 552233                if (value > JsonCommentHandling.Allow)
 034                {
 035                    ThrowHelper.ThrowArgumentOutOfRangeException_CommentEnumMustBeInRange(nameof(value));
 36                }
 37
 552238                _commentHandling = value;
 552239            }
 40        }
 41
 42        /// <summary>
 43        /// Gets or sets the maximum depth allowed when reading JSON, with the default (i.e. 0) indicating a max depth o
 44        /// </summary>
 45        /// <exception cref="ArgumentOutOfRangeException">
 46        /// Thrown when the max depth is set to a negative value.
 47        /// </exception>
 48        /// <remarks>
 49        /// Reading past this depth will throw a <exception cref="JsonException"/>.
 50        /// </remarks>
 51        public int MaxDepth
 52        {
 10537753            readonly get => _maxDepth;
 54            set
 1104455            {
 1104456                if (value < 0)
 057                {
 058                    ThrowHelper.ThrowArgumentOutOfRangeException_MaxDepthMustBePositive(nameof(value));
 59                }
 60
 1104461                _maxDepth = value;
 1104462            }
 63        }
 64
 65        /// <summary>
 66        /// Defines whether an extra comma at the end of a list of JSON values in an object or array
 67        /// is allowed (and ignored) within the JSON payload being read.
 68        /// </summary>
 69        /// <remarks>
 70        /// By default, it's set to false, and <exception cref="JsonException"/> is thrown if a trailing comma is encoun
 71        /// </remarks>
 2131472        public bool AllowTrailingCommas { get; set; }
 73
 74        /// <summary>
 75        /// Defines whether the <see cref="Utf8JsonReader"/> should tolerate
 76        /// zero or more top-level JSON values that are whitespace separated.
 77        /// </summary>
 78        /// <remarks>
 79        /// By default, it's set to false, and <exception cref="JsonException"/> is thrown if trailing content is encoun
 80        /// </remarks>
 83681        public bool AllowMultipleValues { get; set; }
 82    }
 83}
 84