< Summary

Information
Class: System.Net.Http.HttpRequestOptions
Assembly: System.Net.Http
File(s): D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\HttpRequestOptions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 48
Coverable lines: 48
Total lines: 104
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
System.Collections.Generic.IReadOnlyDictionary<System.String,System.Object>.TryGetValue(...)100%110%
System.Collections.Generic.IDictionary<System.String,System.Object>.Add(...)100%110%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Add(...)100%110%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Clear()100%110%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Contains(...)100%110%
System.Collections.Generic.IDictionary<System.String,System.Object>.ContainsKey(...)100%110%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.CopyTo(...)100%110%
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.GetEnumerator()100%110%
System.Collections.IEnumerable.GetEnumerator()100%110%
System.Collections.Generic.IDictionary<System.String,System.Object>.Remove(...)100%110%
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Remove(...)100%110%
System.Collections.Generic.IReadOnlyDictionary<System.String,System.Object>.ContainsKey(...)100%110%
System.Collections.Generic.IDictionary<System.String,System.Object>.TryGetValue(...)100%110%
.ctor()100%110%
TryGetValue(...)0%660%
Set(...)100%110%
DebuggerToString()100%110%
.ctor(...)100%110%

File(s)

D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\HttpRequestOptions.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.Collections.Generic;
 5using System.Diagnostics;
 6using System.Diagnostics.CodeAnalysis;
 7
 8namespace System.Net.Http
 9{
 10    /// <summary>
 11    /// Represents a collection of options for an HTTP request.
 12    /// </summary>
 13    [DebuggerDisplay("{DebuggerToString(),nq}")]
 14    [DebuggerTypeProxy(typeof(HttpRequestOptionsDebugView))]
 15    public sealed class HttpRequestOptions : IDictionary<string, object?>, IReadOnlyDictionary<string, object?>
 16    {
 017        private Dictionary<string, object?> Options { get; } = new Dictionary<string, object?>();
 018        bool IReadOnlyDictionary<string, object?>.TryGetValue(string key, out object? value) => Options.TryGetValue(key,
 019        object? IReadOnlyDictionary<string, object?>.this[string key] => Options[key];
 020        IEnumerable<string> IReadOnlyDictionary<string, object?>.Keys => Options.Keys;
 021        IEnumerable<object?> IReadOnlyDictionary<string, object?>.Values => Options.Values;
 22        object? IDictionary<string, object?>.this[string key]
 23        {
 24            get
 025            {
 026                return Options[key];
 027            }
 28            set
 029            {
 030                Options[key] = value;
 031            }
 32        }
 033        ICollection<string> IDictionary<string, object?>.Keys => Options.Keys;
 034        ICollection<object?> IDictionary<string, object?>.Values => Options.Values;
 035        int ICollection<KeyValuePair<string, object?>>.Count => Options.Count;
 036        bool ICollection<KeyValuePair<string, object?>>.IsReadOnly => ((IDictionary<string, object?>)Options).IsReadOnly
 037        void IDictionary<string, object?>.Add(string key, object? value) => Options.Add(key, value);
 038        void ICollection<KeyValuePair<string, object?>>.Add(KeyValuePair<string, object?> item) => ((IDictionary<string,
 039        void ICollection<KeyValuePair<string, object?>>.Clear() => Options.Clear();
 040        bool ICollection<KeyValuePair<string, object?>>.Contains(KeyValuePair<string, object?> item) => ((IDictionary<st
 041        bool IDictionary<string, object?>.ContainsKey(string key) => Options.ContainsKey(key);
 42        void ICollection<KeyValuePair<string, object?>>.CopyTo(KeyValuePair<string, object?>[] array, int arrayIndex) =>
 043            ((IDictionary<string, object?>)Options).CopyTo(array, arrayIndex);
 044        IEnumerator<KeyValuePair<string, object?>> IEnumerable<KeyValuePair<string, object?>>.GetEnumerator() => Options
 045        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => ((System.Collections.IEnumerabl
 046        bool IDictionary<string, object?>.Remove(string key) => Options.Remove(key);
 047        bool ICollection<KeyValuePair<string, object?>>.Remove(KeyValuePair<string, object?> item) => ((IDictionary<stri
 048        bool IReadOnlyDictionary<string, object?>.ContainsKey(string key) => Options.ContainsKey(key);
 049        bool IDictionary<string, object?>.TryGetValue(string key, out object? value) => Options.TryGetValue(key, out val
 050        int IReadOnlyCollection<KeyValuePair<string, object?>>.Count => Options.Count;
 51
 52        /// <summary>
 53        /// Initializes a new instance of the HttpRequestOptions class.
 54        /// </summary>
 055        public HttpRequestOptions() { }
 56
 57        /// <summary>
 58        /// Gets the value of a given HTTP request option.
 59        /// </summary>
 60        /// <param name="key">Strongly typed key to get the value of HTTP request option. For example <code>new HttpRequ
 61        /// <param name="value">Returns the value of HTTP request option.</param>
 62        /// <typeparam name="TValue">The type of the HTTP value as defined by <code>key</code> parameter.</typeparam>
 63        /// <returns>True, if an option is retrieved.</returns>
 64        public bool TryGetValue<TValue>(HttpRequestOptionsKey<TValue> key, [MaybeNullWhen(false)] out TValue value)
 065        {
 066            if (Options.TryGetValue(key.Key, out object? _value) && _value is TValue tvalue)
 067            {
 068                value = tvalue;
 069                return true;
 70            }
 71
 072            value = default(TValue);
 073            return false;
 074        }
 75
 76        /// <summary>
 77        /// Sets the value of a given request option.
 78        /// </summary>
 79        /// <param name="key">Strongly typed key to get the value of HTTP request option. For example <code>new HttpRequ
 80        /// <param name="value">The value of the HTTP request option.</param>
 81        /// <typeparam name="TValue">The type of the HTTP value as defined by <code>key</code> parameter.</typeparam>
 82        public void Set<TValue>(HttpRequestOptionsKey<TValue> key, TValue value)
 083        {
 084            Options[key.Key] = value;
 085        }
 86
 087        private string DebuggerToString() => $"Count = {Options.Count}";
 88
 089        private sealed class HttpRequestOptionsDebugView(HttpRequestOptions options)
 90        {
 91            [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
 92            public KeyValuePair<string, object?>[] Items
 93            {
 94                get
 095                {
 096                    var dictionary = (IDictionary<string, object?>)options;
 097                    var items = new KeyValuePair<string, object?>[dictionary.Count];
 098                    dictionary.CopyTo(items, 0);
 099                    return items;
 0100                }
 101            }
 102        }
 103    }
 104}

Methods/Properties

Options()
System.Collections.Generic.IReadOnlyDictionary<System.String,System.Object>.TryGetValue(System.String,System.Object&)
em.Collections.Generic.IReadOnlyDictionary<System.String,System.Object>.get_Item(System.String)
em.Collections.Generic.IReadOnlyDictionary<System.String,System.Object>.get_Keys()
em.Collections.Generic.IReadOnlyDictionary<System.String,System.Object>.get_Values()
em.Collections.Generic.IDictionary<System.String,System.Object>.get_Item(System.String)
em.Collections.Generic.IDictionary<System.String,System.Object>.set_Item(System.String,System.Object)
em.Collections.Generic.IDictionary<System.String,System.Object>.get_Keys()
em.Collections.Generic.IDictionary<System.String,System.Object>.get_Values()
em.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.get_Count()
em.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.get_IsReadOnly()
System.Collections.Generic.IDictionary<System.String,System.Object>.Add(System.String,System.Object)
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Add(System.Collections.Generic.KeyValuePair`2<System.String,System.Object>)
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Clear()
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Contains(System.Collections.Generic.KeyValuePair`2<System.String,System.Object>)
System.Collections.Generic.IDictionary<System.String,System.Object>.ContainsKey(System.String)
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.CopyTo(System.Collections.Generic.KeyValuePair`2<System.String,System.Object>[],System.Int32)
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.GetEnumerator()
System.Collections.IEnumerable.GetEnumerator()
System.Collections.Generic.IDictionary<System.String,System.Object>.Remove(System.String)
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Remove(System.Collections.Generic.KeyValuePair`2<System.String,System.Object>)
System.Collections.Generic.IReadOnlyDictionary<System.String,System.Object>.ContainsKey(System.String)
System.Collections.Generic.IDictionary<System.String,System.Object>.TryGetValue(System.String,System.Object&)
em.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.get_Count()
.ctor()
TryGetValue(System.Net.Http.HttpRequestOptionsKey`1<TValue>,TValue&)
Set(System.Net.Http.HttpRequestOptionsKey`1<TValue>,TValue)
DebuggerToString()
.ctor(System.Net.Http.HttpRequestOptions)
Items()