You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We built some extension methods around RegisterMapping to register multiple types with a single call. So we are using it quite frequently. Now we ran into a problem that we cannot resolve an interface type with a covariant type parameter, when registering it by RegisterMapping. See the following example:
varcontainer=new Container();// Register the implementation as itself
container.Register(Made.Of(()=>newList<SubClass>()));// Register the interface with base type parameter
container.RegisterMapping<IReadOnlyList<BaseClass>,List<SubClass>>();// Resolving IReadOnlyList<BaseClass> crashes herevarbaseClassList= container.Resolve<IReadOnlyList<BaseClass>>();
The following is the message of the thrown exception:
DryIoc.ContainerException : code: Error.RegisteringImplementationNotAssignableToServiceType;
message: Registering implementation type List<SubClass> is not assignable to service type IReadOnlyList<BaseClass>.
I will provide a failing test and some working tests containing alternatives/workarounds that are sufficient for us, now. But it would be nice, if this issue got fixed.
The text was updated successfully, but these errors were encountered:
We built some extension methods around
RegisterMapping
to register multiple types with a single call. So we are using it quite frequently. Now we ran into a problem that we cannot resolve an interface type with a covariant type parameter, when registering it byRegisterMapping
. See the following example:The following is the message of the thrown exception:
I will provide a failing test and some working tests containing alternatives/workarounds that are sufficient for us, now. But it would be nice, if this issue got fixed.
The text was updated successfully, but these errors were encountered: