Why does interface return object instead of generic parameter type?

Viewed 40
namespace Microsoft.AspNetCore.Http;
public interface IEndpointFilter
{
    ValueTask<object?> InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next);
}

I am wondering why the above interface is not made as follows?

namespace Microsoft.AspNetCore.Http;
public interface<T> IEndpointFilter
{
    ValueTask<T?> InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next);
}
1 Answers

while using generic type, you force the developer to use a type to implement the methods which may be confusing or not necessary here

Related