< Summary

Information
Line coverage
76%
Covered lines: 13
Uncovered lines: 4
Coverable lines: 17
Total lines: 83
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)

C:\h\w\B31A098C\w\BB5A0A33\e\runtime-utils\Runner\runtime\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        {
 5013029            readonly get => _commentHandling;
 30            set
 5592431            {
 5592432                Debug.Assert(value >= 0);
 5592433                if (value > JsonCommentHandling.Allow)
 034                {
 035                    ThrowHelper.ThrowArgumentOutOfRangeException_CommentEnumMustBeInRange(nameof(value));
 36                }
 37
 5592438                _commentHandling = value;
 5592439            }
 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        {
 6015253            readonly get => _maxDepth;
 54            set
 5731655            {
 5731656                if (value < 0)
 057                {
 058                    ThrowHelper.ThrowArgumentOutOfRangeException_MaxDepthMustBePositive(nameof(value));
 59                }
 60
 5731661                _maxDepth = value;
 5731662            }
 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>
 5592472        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>
 902081        public bool AllowMultipleValues { get; set; }
 82    }
 83}