Skip to content

Amortise HTTP Result Content-Type arrays #56525

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

Merged
merged 1 commit into from
Jul 15, 2024

Conversation

martincostello
Copy link
Member

Amortise Content-Type arrays

Amortise the Content-Type arrays used for HTTP result endpoint metadata.

Description

  • Amortise arrays used for TypedResults' metadata.
  • Use ProducesResponseTypeMetadata.CreateUnvalidated() to bypass Content-Type validation for these static values. If the InternalsVisibleTo is undesirable, this could be reverted but this would need the re-used content-types to a string[], which then means they could in theory be edited at runtime via a cast as the compiler generated <>z__ReadOnlyArray`1 type would no longer be used for the collection expression.
  • Add and use constant for application/octet-stream.

The changes resolve a number of CA1861, IDE0028 and IDE0300 analyser suggestions.

The theory is that the re-use of the arrays and ability to bypass the Content-Type validation will reduce the an application's memory usage and speed up the population of endpoint metadata.

- Amortise arrays used for `TypedResults`' metadata.
- Use `ProducesResponseTypeMetadata.CreateUnvalidated` to bypass `Content-Type` validation for static values.
- Add and use constant for `application/octet-stream`.
@ghost ghost added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Jun 29, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jun 29, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Jul 8, 2024
@martincostello martincostello removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Jul 8, 2024
@martincostello martincostello reopened this Jul 8, 2024
@dotnet-policy-service dotnet-policy-service bot added this to the 9.0-preview7 milestone Jul 8, 2024
@BrennanConroy
Copy link
Member

The changes resolve a number of CA1861, IDE0028 and IDE0300 analyser suggestions.

Wonder if we should add these to our .editorconfig

Copy link
Member

@BrennanConroy BrennanConroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@BrennanConroy BrennanConroy merged commit bd50a68 into dotnet:main Jul 15, 2024
27 checks passed
@martincostello martincostello deleted the amortise-arrays branch July 15, 2024 22:11
@martincostello
Copy link
Member Author

The changes resolve a number of CA1861, IDE0028 and IDE0300 analyser suggestions.

Wonder if we should add these to our .editorconfig

#56814

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants