You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into what I consider to be a bug in v3.3.1 - specifically in the work done to resolve issue #252.
Here some code that exhibits the problem:
var kernel = new StandardKernel();
var list1 = kernel.Get<List<ChildA>>();
var child1 = kernel.Get<ChildA>();
var list2 = kernel.Get<List<ChildA>>();
List1 is returned as an empty List.
After a request for an instance of ChildA is made, subsequent requests for List return a List containing a new instance of ChildA.
As there is no explicit binding, I don't expect the second list to contain an item.
Furthermore, the particular scenario where this has manifested itself is where I use Ninject as a general object factory during JSON deserialization. The deserialization process can arbitrarily ask for items or lists of items depending on the object being deserialized. In this scenario, I never want the requested list to be populated with items - I just want an empty list of the requested type. Ideally there would be a way to opt-in (or out) of the IEnumerable<> functionality.
The text was updated successfully, but these errors were encountered:
I wonder if the Array/List/IEnumerable support added to KernelBase.Resolve() in #252 could have been implemented as an IBindingResolver (and maybe a custom Binding)? That would at least allow the possibility of customising or disabling this functionality rather than having it baked right into the Kernel.
Hello,
I've run into what I consider to be a bug in v3.3.1 - specifically in the work done to resolve issue #252.
Here some code that exhibits the problem:
List1 is returned as an empty List.
After a request for an instance of ChildA is made, subsequent requests for List return a List containing a new instance of ChildA.
As there is no explicit binding, I don't expect the second list to contain an item.
Furthermore, the particular scenario where this has manifested itself is where I use Ninject as a general object factory during JSON deserialization. The deserialization process can arbitrarily ask for items or lists of items depending on the object being deserialized. In this scenario, I never want the requested list to be populated with items - I just want an empty list of the requested type. Ideally there would be a way to opt-in (or out) of the IEnumerable<> functionality.
The text was updated successfully, but these errors were encountered: