khellang / Scrutor

Assembly scanning and decoration extensions for Microsoft.Extensions.DependencyInjection
MIT License
3.58k stars 234 forks source link

Problem to use Scan with IMediatR #144

Open MatheusXavier opened 3 years ago

MatheusXavier commented 3 years ago

I'm using IMediatR lib, so before Scrutor I registered my Queries like that: services.AddTransient<IRequestHandler<FindPlaceQuery, Result<List<FindPlaceDto>>>, FindPlaceQueryHandler>();

Now, with Scan I did like that and it's wooking perfectly:

                scan.FromAssemblies(typeof(CreateClientCommand).GetTypeInfo().Assembly)
                    .AddClasses(classes => classes.AssignableTo(typeof(IRequestHandler<,>)))
                        .AsImplementedInterfaces()
                        .WithTransientLifetime()
                    .AddClasses(classes => classes.AssignableTo(typeof(INotificationHandler<>)))
                        .AsImplementedInterfaces()
                        .WithTransientLifetime()
                    .AddClasses()
                        .AsMatchingInterface());

But I have a different scenario where it doesn't work, when i'm using a generic type for my query the Scrutor could not solve de dependency: services.AddTransient<IRequestHandler<GetConfigurationValueByKeyQuery<int>, int>, GetConfigurationValueByKeyQueryHandler<int>>()

khellang commented 3 years ago

there's a lot of bugs in there

@jposert That's a pretty pathetic bug report. Any more details would be welcome. Preferably in a separate issue. Scrutor has 19,021,071 downloads and very few of those users (including you) have bothered to file a bug report, so either there's not "a lot of bugs in there" or they can't be very severe. I'm guessing it's the former and you're full of 💩😅 Looking forward to your proper bug report 😬

zachrybaker commented 3 years ago

guys, guys....