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
Duplicates when Scanning Assemblies with latest .NET 7 SDK versions #200
Comments
Hi @markreed-hearst! 👋🏻 Haven't heard about this before. It's probably worth raising this with Microsoft if you think they broke something. Otherwise we'd probably need more details or a repro 😅 |
Here is a repro: |
Used |
Skip didn't work for me because it only filters on the ServiceType of the descriptor, so filters too many things out. I I write a similar custom strategy that also filter on ImplementationType then I get the effect I desire (I work with mark up above)
|
I wonder if this is specific to |
Maybe, but Mark's repro repo doesn't seem to have multiple references to the same assembly. |
Hi,
We are using Scrutor as part of our .NET Core Web Api implementation. The following code is used to scan dependencies of the api and register implementations of the handler interfaces:
internal static IServiceCollection AutoRegisterHandlers(this IServiceCollection services) { services.Scan(scan => scan.FromApplicationDependencies() .AddClasses(classes => classes.AssignableTo<IHandleGetRequests>()).As<IHandleGetRequests>() .AddClasses(classes => classes.AssignableTo<IHandleDeleteRequests>()).As<IHandleDeleteRequests>() .AddClasses(classes => classes.AssignableTo(typeof(IHandlePatchRequests<>))).AsImplementedInterfaces() .AddClasses(classes => classes.AssignableTo(typeof(IHandlePutRequests<>))).AsImplementedInterfaces() .AddClasses(classes => classes.AssignableTo(typeof(IHandlePostRequests<>))).AsImplementedInterfaces()); return services; }
With version 7.0.100 of the .NET SDK the above code works as expected and the results of the call to services.Scan include one entry for each implementation of the interfaces. However after upgrading the SDK to 7.0.2** (e.g. the latest version 7.0.203) then the assembly scanning produces duplicates for each interface, this in turn creates duplicates in our registration of the handlers and results in
Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints
errors at runtime.We are aware of the RegistrationStrategy stuff and we are looking at amending our code to make use of this with either Skip or Replace but wanted to check if you are aware of the issue and whether there are any plans to release an update of Scrutor in response to this or not?
The text was updated successfully, but these errors were encountered: