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.
[X] Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
[X] 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.
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 https://github.com/dotnet/aspnetcore/issues/43125#issuecomment-1218534849 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