Skip to content

HeaderNames now contains static readonly fields instead of const fields #14901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tratcher opened this issue Oct 2, 2019 · 0 comments · Fixed by #15044
Closed

HeaderNames now contains static readonly fields instead of const fields #14901

Tratcher opened this issue Oct 2, 2019 · 0 comments · Fixed by #15044
Assignees
Labels
breaking-change Indicates a .NET Core breaking change

Comments

@Tratcher
Copy link
Member

Tratcher commented Oct 2, 2019

HeaderNames now contains static readonly fields instead of const fields

The static Microsoft.Net.Http.Headers.HeaderNames class contains string fields representing various common header names (e.g. HeaderNames.Origin). Starting in ASP.NET Core 3.0 Preview 5, these will change from const fields to static readonly fields.

See dotnet/aspnetcore#9514 for discussion.

Version introduced

3.0

Old behavior

These fields used to be const

New behavior

These fields are now static readonly.

Reason for change

The change prevents the values from being embedded across assembly boundaries allowing for value corrections as needed. It also enables faster reference equality checks.

Recommended action

Recompile against 3.0. Source code that used these fields as an attribute argument, a case in a switch statement, or when defining another constant will no longer be able to do so. To work around this break, developers can switch to using self-defined header name constants or string literals.

Category

  • ASP.NET Core

Affected APIs

All fields on Microsoft.Net.Http.Headers.HeaderNames


Issue metadata

  • Issue type: breaking-change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Indicates a .NET Core breaking change
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants