Skip to content
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

[Breaking change]: IEndpointMetadataProvider and IEndpointParameterMetadataProvider interface changes in 7.0 RC2 #496

Open
2 of 3 tasks
halter73 opened this issue Oct 6, 2022 · 0 comments
Labels
7.0.0 Announcement Breaking change Documented The breaking change has been published to the .NET Core docs

Comments

@halter73
Copy link
Member

halter73 commented Oct 6, 2022

Description

In ASP.NET Core 7 RC2, the IEndpointMetadataProvider and IEndpointParameterMetadataProvider interfaces introduced in preview 4 have been updated to take an EndpointBuilder rather than a EndpointMetadataContext or EndpointParameterMetadataContext.

Version

.NET 7 RC 2

Previous behavior

The PopulateMetadata methods on both interfaces took their respective context arguments as a single parameter. Both contexts included services (IServiceProvider) and endpoint metadata (IList<object>).

EndpointMetadataContext included the MethodInfo for the minimal route handler MVC action that took the implementing type as a parameter or returned it. EndpointParameterMetadataContext provided ParameterInfo and could only be used on parameter types.

New behavior

Now in RC2, both interfaces' PopulateMetadata method take an EndpointBuilder as their second parameter. The EndpointBuilder provides access to the application services (IServiceProvider) and endpoint metadata (IList<object>) previously provided by EndpointMetadataContext and EndpointParameterMetadataContext.

Now, IEndpointMetadataProvider takes a MethodInfo and IEndpointParameterMetadataProvider takes a ParameterInfo as their first parameter.

Both EndpointMetadataContext and EndpointParameterMetadataContext have been removed.

See dotnet/aspnetcore#43125 (comment) for an API diff.

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
  • Source incompatible: Source code may encounter a breaking change in behavior when targeting the new runtime/component/SDK, such as compile errors or different run-time behavior.
  • Behavioral change: Existing code and binaries may experience different run-time behavior.

Reason for change

The metadata providers now get access to more metadata like the RoutePattern (with a downcast) and DisplayName via the EndpointBuilder, and this allowed us to delete unnecessary context types.

Recommended action

Update implementations of IEndpointMetadataProvider and IEndpointParameterMetadataProvider to access the information necessary from the new parameters. There should be nothing that was available via the contexts previously that are unavailable via PopulateMetadata's new parameters.

Affected APIs

  • Parameters changed: Microsoft.AspNetCore.Http.Metadata.IEndpointMetadataProvider.PopulateMetadata
  • Parameters changed: Microsoft.AspNetCore.Http.Metadata.IEndpointParameterMetadataProvider.PopulateMetadata
  • Removed: Microsoft.AspNetCore.Http.Metadata.EndpointMetadataContext
  • Removed: Microsoft.AspNetCore.Http.Metadata.EndpointParameterMetadataContext
@halter73 halter73 closed this as completed Oct 6, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Oct 6, 2022
@halter73 halter73 reopened this Oct 6, 2022
@gewarren gewarren added the Documented The breaking change has been published to the .NET Core docs label Oct 11, 2022
@guardrex guardrex added the 7.0.0 label Nov 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
7.0.0 Announcement Breaking change Documented The breaking change has been published to the .NET Core docs
Projects
None yet
Development

No branches or pull requests

3 participants