jbogard / MediatR.Extensions.Microsoft.DependencyInjection

MediatR extensions for Microsoft.Extensions.DependencyInjection
MIT License
326 stars 90 forks source link

Type should have same number of generic Parameters #83

Closed joaomatossilva closed 2 years ago

joaomatossilva commented 4 years ago

Found a situation where a generic type doesn't have the entire number of parameter to satisfy.

take this type for example:

    public class HandlerAdapter<THandler, TRequest> : INotificationHandler<TRequest>
        where TRequest : INotification
        where THandler : ISomeOtherStuff<TRequest>
    {
        private readonly THandler innerStuff;

        public HandlerShim(THandler innerStuff)
        {
            this.innerStuff = innerStuff;
        }

        public async Task Handle(TRequest notification, CancellationToken cancellationToken)
        {
            await innerStuff.Stuff(notification);
        }
    }

results in the following exception being thrown: System.ArgumentException: 'The number of generic arguments provided doesn't equal the arity of the generic type definition. (Parameter 'instantiation')'

joaomatossilva commented 4 years ago

Actually not sure if the is different comparision shouldn't be a greater if instead

markmillercc commented 2 years ago

I started working on a PR to fix this, based on an issue I reported here: https://github.com/jbogard/MediatR/issues/674

But I see this one, which appears to do the same thing I need. Is there a reason it hasn't been approved?