Skip to content

Parameter name to WithConstructorArgumentFromControllerAttribute is not enforced #42

@mikesmithphl

Description

@mikesmithphl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions