-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implemented
Description
Background and Motivation
IHeaderDictionary
has DIM properties for many commonly used headers: https://github.com/dotnet/aspnetcore/blob/ff2148be7592be83f1f88e2f372ef04f02fdfdb8/src/Http/Http.Features/src/IHeaderDictionary.Keyed.cs
These properties are better because:
- Strongly typed so no chance of typos.
- Faster because they directly fetch the known header value from the underlying collection.
Proposed API
An analyzer that looks for indexer use with a name that matches a property on IHeaderDictionary
. This will only apply to header names that have a property, e.g.
var accepts = context.Request.Headers["accepts"]; // <- valid to fix
var id = context.Request.Headers["contoso-id"]; // <- ignored
Usage Examples
Alternative Designs
Risks
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implemented