Is auto binding a feature? #403
Replies: 1 comment 1 reply
-
I'm assuming that you are referring to the fact that you can create an instance of basically any class with Ninject without defining a binding for it. For example, assuming that That is indeed a feature, although one that I have grown to dislike 😝. I call it "automatic implicit self bindings" and it originates in the SelfBindingResolver class which is automatically added to the Ninject kernel instance. It is documented here https://github.com/ninject/Ninject/wiki/Building-an-IMissingBindingResolver-Component . While I can definitely see the utility in automatic self bindings, I have also seen that it can cause some issues that are very hard to track down if somebody accidentally injects a concrete class instead of the associated interface as they are supposed to. The fact that it just "works" does not imply that it works correctly since the interface binding can have sophisticated logic that will be completely side-stepped when the concrete instance is injected directly. In any case, while it isn't currently not configurable through the |
Beta Was this translation helpful? Give feedback.
-
I am using Ninject with a .NET Framework 4.8 project, and I just noticed that it seems to be auto-registering things.
This is not a problem (it's actually very convenient); however, I was wondering if there is any kind of documentation or mention of this as a feature.
Beta Was this translation helpful? Give feedback.
All reactions