Parameter name to WithConstructorArgumentFromControllerAttribute is not enforced
mikesmithphl opened this issue · 0 comments
mikesmithphl commented
Given the following code
this.BindFilter<FooFilter>(FilterScope.Controller, order: 0)
.WhenControllerHas<FooAttribute>()
.WithConstructorArgumentFromControllerAttribute<FooAttribute>(parameterName, someLambda);
I've found that the parameterName passed in must not be null or empty, but as long as a type matches, it will succeed. My expectation was that it would fail to bind if it couldn't find a parameter with the proper name AND type provided. Ninject seems to prefer Constructors with more dependencies, so it's possible you could attempt to override a parameter of one constructor with less parameters but will instead override the other that may contain a non-matching name.
For example:
public class FooFilter : IFooFilter
{
public FooFilter(IFoo f) { .. }
public FooFilter(IFoo foo, IBar bar) { .. }
}
Specifying a constructor parameter name of "f"
will still prefer the latter constructor. The parameter name seems to be ignored.