[Breaking change]: IEndpointMetadataProvider and IEndpointParameterMetadataProvider interface changes in 7.0 RC2 #496
Labels
7.0.0
Announcement
Breaking change
Documented
The breaking change has been published to the .NET Core docs
Description
In ASP.NET Core 7 RC2, the
IEndpointMetadataProvider
andIEndpointParameterMetadataProvider
interfaces introduced in preview 4 have been updated to take an EndpointBuilder rather than aEndpointMetadataContext
orEndpointParameterMetadataContext
.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 theMethodInfo
for the minimal route handler MVC action that took the implementing type as a parameter or returned it.EndpointParameterMetadataContext
providedParameterInfo
and could only be used on parameter types.New behavior
Now in RC2, both interfaces'
PopulateMetadata
method take anEndpointBuilder
as their second parameter. TheEndpointBuilder
provides access to the application services (IServiceProvider
) and endpoint metadata (IList<object>
) previously provided byEndpointMetadataContext
andEndpointParameterMetadataContext
.Now,
IEndpointMetadataProvider
takes aMethodInfo
andIEndpointParameterMetadataProvider
takes aParameterInfo
as their first parameter.Both
EndpointMetadataContext
andEndpointParameterMetadataContext
have been removed.See dotnet/aspnetcore#43125 (comment) for an API diff.
Type of breaking change
Reason for change
The metadata providers now get access to more metadata like the
RoutePattern
(with a downcast) andDisplayName
via theEndpointBuilder
, and this allowed us to delete unnecessary context types.Recommended action
Update implementations of
IEndpointMetadataProvider
andIEndpointParameterMetadataProvider
to access the information necessary from the new parameters. There should be nothing that was available via the contexts previously that are unavailable viaPopulateMetadata
's new parameters.Affected APIs
Microsoft.AspNetCore.Http.Metadata.IEndpointMetadataProvider.PopulateMetadata
Microsoft.AspNetCore.Http.Metadata.IEndpointParameterMetadataProvider.PopulateMetadata
Microsoft.AspNetCore.Http.Metadata.EndpointMetadataContext
Microsoft.AspNetCore.Http.Metadata.EndpointParameterMetadataContext
The text was updated successfully, but these errors were encountered: