diff --git a/src/libraries/System.Net.Http/ref/System.Net.Http.cs b/src/libraries/System.Net.Http/ref/System.Net.Http.cs index 1652b5804ae81..46d2b57abfc78 100644 --- a/src/libraries/System.Net.Http/ref/System.Net.Http.cs +++ b/src/libraries/System.Net.Http/ref/System.Net.Http.cs @@ -277,8 +277,10 @@ public HttpRequestOptionsKey(string key) {} public string Key { get { throw null; } } } - public sealed class HttpRequestOptions : System.Collections.Generic.IDictionary + public sealed class HttpRequestOptions : System.Collections.Generic.IDictionary, System.Collections.Generic.IReadOnlyDictionary { + bool System.Collections.Generic.IReadOnlyDictionary.ContainsKey(string key) { throw null; } + int System.Collections.Generic.IReadOnlyCollection>.Count { get { throw null; } } void System.Collections.Generic.IDictionary.Add(string key, object? value) { throw null; } System.Collections.Generic.ICollection System.Collections.Generic.IDictionary.Keys { get { throw null; } } System.Collections.Generic.ICollection System.Collections.Generic.IDictionary.Values { get { throw null; } } @@ -297,6 +299,10 @@ public sealed class HttpRequestOptions : System.Collections.Generic.IDictionary< System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } public bool TryGetValue(HttpRequestOptionsKey key, [MaybeNullWhen(false)] out TValue value) { throw null; } public void Set(HttpRequestOptionsKey key, TValue value) { throw null; } + bool System.Collections.Generic.IReadOnlyDictionary.TryGetValue(string key, out object? value) { throw null; } + object? System.Collections.Generic.IReadOnlyDictionary.this[string key] { get { throw null; } } + System.Collections.Generic.IEnumerable System.Collections.Generic.IReadOnlyDictionary.Keys { get { throw null; } } + System.Collections.Generic.IEnumerable System.Collections.Generic.IReadOnlyDictionary.Values { get { throw null; } } } public partial class HttpResponseMessage : System.IDisposable diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestOptions.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestOptions.cs index 20116559c8930..75cb6d8d7e6e1 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestOptions.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestOptions.cs @@ -9,9 +9,13 @@ namespace System.Net.Http /// /// Represents a collection of options for an HTTP request. /// - public sealed class HttpRequestOptions : IDictionary + public sealed class HttpRequestOptions : IDictionary, IReadOnlyDictionary { private Dictionary Options { get; } = new Dictionary(); + bool IReadOnlyDictionary.TryGetValue(string key, out object? value) => Options.TryGetValue(key, out value); + object? IReadOnlyDictionary.this[string key] => Options[key]; + IEnumerable IReadOnlyDictionary.Keys => Options.Keys; + IEnumerable IReadOnlyDictionary.Values => Options.Values; object? IDictionary.this[string key] { get @@ -38,7 +42,9 @@ public sealed class HttpRequestOptions : IDictionary System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => ((System.Collections.IEnumerable)Options).GetEnumerator(); bool IDictionary.Remove(string key) => Options.Remove(key); bool ICollection>.Remove(KeyValuePair item) => ((IDictionary)Options).Remove(item); + bool IReadOnlyDictionary.ContainsKey(string key) => Options.ContainsKey(key); bool IDictionary.TryGetValue(string key, out object? value) => Options.TryGetValue(key, out value); + int IReadOnlyCollection>.Count => Options.Count; /// /// Initializes a new instance of the HttpRequestOptions class.