Skip to content

Resolution does not handle default constructor parameters #50

@dalewking

Description

@dalewking

Say I have a class that only has a constructor with an optional parameter like so:

public class Foo
{
    public Foo(int i = -1) { }
}

And I register it and try to resolve it:

container.Register<Foo>();
container.Resolve<Foo>();

Then TinyIoC will fail to resolve it because it doesn't think it has a value for the constructor parameter, but it could have used the default values.

It would require replacing the default parameters with explicit constructor overloads to work around this, but that may not always be possible (we may not have the code).

For info on how to reflectively invoke using the default parameter see: http://stackoverflow.com/questions/2421994/invoking-methods-with-optional-parameters-through-reflection

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions