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
When a class inherits from the same generic interface twice, an error message like below is shown:
The implementation type CGeneric'1 does not support the interface ISingleGenericWithInModifier'1.
The following test should pass:
publicclassTestClass{publicinterfaceISimpleInterface{}publicinterfaceISingleGeneric<T>{}publicinterfaceISingleGenericWithInModifier<inT>{}publicinterfaceISingleGenericWithOutModifier<outT>{}publicclassCGeneric<T>:ISingleGeneric<T>{}publicclassCSimple:ISimpleInterface{}publicclassCDoubleInheritGeneric<T>:ISingleGenericWithInModifier<ISingleGeneric<T>>,ISingleGenericWithInModifier<CGeneric<T>>{}[Fact]publicvoidCanResolveComponentWhenItInheritsFromTheSameGenericInterfaceTwice(){varbuilder=newContainerBuilder();builder.RegisterGeneric(typeof(CDoubleInheritGeneric<>)).As(typeof(ISingleGenericWithInModifier<>));varcontainer=builder.Build();// These should resolve because it inherits from ISingleGenericWithInModifier with both as nested generic argumentsAssert.True(container.IsRegistered<ISingleGenericWithInModifier<ISingleGeneric<int>>>());Assert.True(container.IsRegistered<ISingleGenericWithInModifier<CGeneric<int>>>());Assert.True(container.IsRegistered<ISingleGenericWithInModifier<ISingleGeneric<CSimple>>>());Assert.True(container.IsRegistered<ISingleGenericWithInModifier<CGeneric<CSimple>>>());// These should not resolve because they do not match the above patternAssert.False(container.IsRegistered<ISingleGenericWithInModifier<int>>());Assert.False(container.IsRegistered<ISingleGenericWithInModifier<ISingleGenericWithOutModifier<int>>>());Assert.False(container.IsRegistered<ISingleGenericWithInModifier<ISingleGenericWithOutModifier<CSimple>>>());}}
The fix is to change the call from Single to First on line 109 of OpenGenericServiceBinder in method GetInterface.
I have tested it locally and all tests pass.
I have created PR #871 with the fix and test for the issue
The text was updated successfully, but these errors were encountered:
Version 4.6.1
When a class inherits from the same generic interface twice, an error message like below is shown:
The implementation type CGeneric'1 does not support the interface ISingleGenericWithInModifier'1.
The following test should pass:
The fix is to change the call from Single to First on line 109 of OpenGenericServiceBinder in method GetInterface.
I have tested it locally and all tests pass.
I have created PR #871 with the fix and test for the issue
The text was updated successfully, but these errors were encountered: