-
-
Notifications
You must be signed in to change notification settings - Fork 239
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
Calling .AsImplementedInterfaces() can result is duplicate service descriptors getting registered #20
Comments
If you have a class I read your pseudocode as saying it's finding Isn't that is what is happening? What do you expect to happen? |
Not quite. Let me see if I can better explain what I am running into. If I have a class ( But if I then execute another I see that this is the result of using the |
Ahh, I see. It's not a problem with Question for @khellang but maybe the solution is making a |
Yeah. Something like that would be helpful. The issue arises for me because I am trying to support the ability to scan for a variable number of interfaces and am trying to abstract the Scrutor code away via a custom extension method. I guess I could try to build up the entire list of interfaces and attempt to do just one Scan operation. I haven't tested that yet, but maybe that wouldn't result in the duplicates. I may see if I can put a PR together that meets my needs. |
Nevermind... I found a way to make this work as I intended without calling Scan more than once. |
@eric-davis Thanks to @adamhathcock (#22), there's now support for calling |
If a class implements multiple interfaces and the following pseudo-code is executed multiple times for each of the different interface types that class implements, the same service descriptor will be registered multiple times.
services.Scan( x => { x.FromAssemblies([ASSEMBLY_COLLECTION]) .AddClasses(classes => classes.AssignableTo([INTERFACE_TYPE])) .AsImplementedInterfaces() .WithTransientLifetime(); });
The text was updated successfully, but these errors were encountered: