Skip to content

Add an Analyzer to recommend against IHeaderDictionary.Add #41362

@Tratcher

Description

@Tratcher

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

IHeaderDictionary.Add throws if duplicate keys are added (Matches IDictionary). Most people want to set or append. They can set using the indexer (IHeaderDictioanry[key] = value) or append by calling Append. This is especially confusing when moving from System.Web where Headers.Add appended.

Describe the solution you'd like

We should add an analyzer that warns people not to use Add, but to use the indexer or Append instead.

Additional context

No response

Metadata

Metadata

Assignees

Labels

analyzerIndicates an issue which is related to analyzer experiencearea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionshelp wantedUp for grabs. We would accept a PR to help resolve this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions