Closed
Description
Map extensions that hang off IEndpointRouteBuilder
return IEndpointConventionBuilder
. This is fine and good.
Can we imagine scenarios where someone wants to return a more strongly typed builder? For example, from gRPC's MapGrpcService
I return an GrpcEndpointRouteBuilder
. It implements convention builder but there is also some gRPC specific stuff on there, and gRPC extension methods.
public class GrpcEndpointRouteBuilder : IEndpointConventionBuilder
{
public GrpcEndpointRouteBuilder ConfigureCrazyGrpcStuff(Action a)
{
a();
return this;
}
}
Today all our IEndpointConventionBuilder
extension methods return IEndpointConventionBuilder
which would make using a strongly typed builder difficult.
routes.MapGrpcService<MyService>()
.RequireAuthorization("policy")
.ConfigureCrazyGrpcStuff(() => {}) // error, reference is no longer the gRPC builder
Should our extension methods be more like:
public TBuilder RequireAuthorization<TBuilder>(TBuilder builder, string policyName) where TBuilder : IEndpointConventionBuilder
{
// stuff
return builder;
}