Closed
Description
Background and motivation
Methods and extension methods that don't modify a dictionary often expect a parameter of IReadOnlyDictionary
instead of IDictionary
.
API Proposal
namespace System.Net.Http
{
public class HttpRequestOptions : IReadOnlyDictionary<string,object>, // NEW
IDictionary<string, object> // EXISTING
{
[...]
}
}
API Usage
var dic = (IReadOnlyDictionary<string,object>)request.Options;
Alternative Designs
No response
Risks
In rare circumstances, a method will have an overload for IDictionary and another overload for IReadOnlyDictionary. This would be ambiguous for HttpRequestOptions, as it is for other dictionaries.