SimonG96 / LightweightIocContainer

A lightweight IOC Container that is powerful enough to do all the things you need it to do.
MIT License
4 stars 2 forks source link

Can't match argument type with an expected interface type in `ResolveConstructorArguments()` #16

Closed SimonG96 closed 5 years ago

SimonG96 commented 5 years ago

If an interface type is expected as a constructor parameter, but the given argument is of the type of the implementation, in the function ResolveConstructorArguments() the parameter can't be assigned to the correct parameter.

This happens because we only check for

fittingArgument = argumentsList.FirstOrGiven<object, InternalResolvePlaceholder>(a => a?.GetType() == parameter.ParameterType);

We also have to check for

parameter.ParameterType.IsInstanceOfType(a)