-
Notifications
You must be signed in to change notification settings - Fork 530
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
Cyclical dependency detection false positive with open generic service #143
Comments
@remogloor I implemented a fix for this issue. Could you review my changes? Link to commit: iappert@1d0121b |
Could you guys align on line endings and spacing or seperate changes from code formatting? Kinda hard to follow what changed otherwise
|
Sorry for that. Habbits... I added the following test:
|
Just make your ctrl+e+f spree in seperate commit ;)
|
@iappert
will lead to a stack overflow instead of an activation exception. |
@remogloor
or
result in a circular dependency of A. Without my change, the example of @halter73 leads to a circular dependency because of the open generic binding, i.e.
Resolving |
This will get you a stackoverflow exception:
|
Agreed. I haven't thought about this case. I will try to find another solution:-). thanks for your help. |
Any update on the status for this? |
We have made a fix where we don't register some of the services as open generics. The issue in ninject still exists and will break user code (or potentially other framework code) |
Any update on this? |
The following code will throw a
Ninject.ActivationException
in the call toGet
claiming that a "A cyclical dependency was detected between the constructors of two services."Even though
IGeneric<>
is resolved twice, there isn't a cyclical dependency becauseIGeneric<>
is activated with two different type parameters which changes the type of its dependency.As indicated by the comment in the Main method, you can work around this exception by registering a closed generic service (i.e.
IGeneric<IServiceA>
orIGeneric<IServiceB>
). If you do this, the call toGet
will return an instance ofGeneric<IServiceA>
as expected.I think this is a bug because the closed generic registration should be subsumed by the open generic registration.
The full exception message reads as follows:
The text was updated successfully, but these errors were encountered: