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
In our code, we had a really weird bug related to Ninject, and according to this stackoverflow answer, the root cause was that the Ninject Factory extension bind Func<T,T,bool> (and possibly other Funcs).
Assume an object such as
public class PriorityQueue<T>(Func<T,T,bool> cmp_func) : IPriorityQueue<T>
{ ... }
and a Factory
public IPriorityQueueFactory
{
IPriorityQueue<T> Create<T>();
}
The expected behavior would be that Ninject will throw an exception, because the constructor argument was not bound. But this will not happen; instead, the factory extension will silently inject the non-user-bound Func<...>.
This is very confusing, and it cost me a long time to track down the bug.
I would assume that for most users, silently adding bindings for something as common as a Func<...> is outside of the expected behavior of a ninject extension.
The problem gets even worse if using custom factories as explained here. Then the bug occurs if the factory extension is in the usings, but behaves correctly otherwise.
The text was updated successfully, but these errors were encountered:
In our code, we had a really weird bug related to Ninject, and according to this stackoverflow answer, the root cause was that the Ninject Factory extension bind Func<T,T,bool> (and possibly other Funcs).
Assume an object such as
and a Factory
The expected behavior would be that Ninject will throw an exception, because the constructor argument was not bound. But this will not happen; instead, the factory extension will silently inject the non-user-bound Func<...>.
This is very confusing, and it cost me a long time to track down the bug.
I would assume that for most users, silently adding bindings for something as common as a Func<...> is outside of the expected behavior of a ninject extension.
The problem gets even worse if using custom factories as explained here. Then the bug occurs if the factory extension is in the usings, but behaves correctly otherwise.
The text was updated successfully, but these errors were encountered: