-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Rename filter extension methods and type name to be more agnostic #42589
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
Comments
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
API review notes: There were a few emails (from me included) that probably could have been GitHub comments, so I'm pasting them here.
We want this for preview7 that closes tomorrow, so we can rename API Approved! namespace Microsoft.AspNetCore.Http;
- public static class RouteHandlerFilterExtensions
+ public static class EndpointFilterExtensions
{
- public static TBuilder AddRouteHandlerFilter<TBuilder>(this TBuilder builder, IRouteHandlerFilter filter);
- public static TBuilder AddRouteHandlerFilter<TBuilder, TFilterType>(this TBuilder builder);
- public static RouteHandlerBuilder AddRouteHandlerFilter<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TFilterType>(this RouteHandlerBuilder builder);
- public static RouteGroupBuilder AddRouteHandlerFilter<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TFilterType>(this RouteGroupBuilder builder);
- public static TBuilder AddRouteHandlerFilter<TBuilder>(this TBuilder builder, Func<RouteHandlerInvocationContext, RouteHandlerFilterDelegate, ValueTask<object?>> routeHandlerFilter);
- public static TBuilder AddRouteHandlerFilter<TBuilder>(this TBuilder builder, Func<RouteHandlerContext, RouteHandlerFilterDelegate, RouteHandlerFilterDelegate> filterFactory);
+ public static TBuilder AddEndpointFilter<TBuilder>(this TBuilder builder, IEndpointFilter filter);
+ public static TBuilder AddEndpointFilter<TBuilder, TFilterType>(this TBuilder builder);
+ public static RouteHandlerBuilder AddEndpointFilter<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TFilterType>(this RouteHandlerBuilder builder);
+ public static RouteGroupBuilder AddEndpointFilter<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TFilterType>(this RouteGroupBuilder builder);
+ public static TBuilder AddEndpointFilter<TBuilder>(this TBuilder builder, Func<EndpointExecutionContext, EndpointFilterDelegate, ValueTask<object?>> endpointFilter);
+ public static TBuilder AddEndpointFilterFactory<TBuilder>(this TBuilder builder, Func<EndpointContext, EndpointFilterDelegate, EndpointFilterDelegate> filterFactory);
}
- public interface IRouteHandlerFilter {}
+ public interface IEndpointFilter {}
- public delegate ValueTask<object?> RouteHandlerFilterDelegate(RouteHandlerInvocationContext context);
+ public delegate ValueTask<object?> EndpointFilterDelegate(EndpointExecutionContext context);
- public class RouteHandlerContext {}
+ public class EndpointFilterFactoryContext {}
- public abstract class RouteHandlerInvocationContext {}
+ public class EndpointFilterInvocationContext {}
- public class DefaultRouteHandlerInvocationContext {}
+ public class DefaultEndpointFilterInvocationContext {}
// EDIT
public sealed class RequestDelegateFactoryOptions
{
- public IReadOnlyList<Func<RouteHandlerContext, RouteHandlerFilterDelegate, RouteHandlerFilterDelegate>>? RouteHandlerFilterFactories { get; init; }
+ public IReadOnlyList<Func<EndpointFilterFactoryContext, EndpointFilterDelegate, EndpointFilterDelegate>>? EndpointFilterFactories { get; init; }
} |
While doing the renames, I noticed we missed namespace Microsoft.AspNetCore.Http;
public sealed class RequestDelegateFactoryOptions
{
- public IReadOnlyList<Func<RouteHandlerContext, RouteHandlerFilterDelegate, RouteHandlerFilterDelegate>>? RouteHandlerFilterFactories { get; init; }
+ public IReadOnlyList<Func<EndpointFilterFactoryContext, EndpointFilterDelegate, EndpointFilterDelegate>>? EndpointFilterFactories { get; init; }
} |
No need for endpoints here? FilterFactories |
That seems a little weird to me only because it breaks the consistency that exists elsewhere. |
In the interest of time and consistency, I'm sticking with |
I won't die on this hill but Endpoint doesnt have an EndpointMetadata property, it has a Metadata property, the extra Endpoint is redundant. |
Not a hill I will die on either (I'd happily approve an API proposal and PR to change it to |
That one make sense because it's not an endpoint. |
Background and Motivation
With changes introduced in preview6, filters can be registered on both routes and route groups. This proposal recommends renaming the type methods in the route filters area to reflect this.
This proposal also recommends using
AddEndpointFilterFactory
to disambiguate between extension method overlands that take a filter factory delegate versus a filter delegate.Proposed API
The text was updated successfully, but these errors were encountered: