Skip to content
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

Parameter name to WithConstructorArgumentFromControllerAttribute is not enforced #42

Open
mikesmithphl opened this issue Jul 19, 2016 · 0 comments

Comments

@mikesmithphl
Copy link

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.

@mikesmithphl mikesmithphl changed the title Parameter name to WithConstructorArgumentFromControllerAttribute doesn't seem to be enforced Parameter name to WithConstructorArgumentFromControllerAttribute is not enforced Jul 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant