Skip to content

[API Proposal]: HttpRequestOptions should implement IReadOnlyDictionary #68149

Closed
@Grauenwolf

Description

@Grauenwolf

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-approvedAPI was approved in API review, it can be implementedarea-System.Net.Httphelp wanted[up-for-grabs] Good issue for external contributors

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions