File tree 2 files changed +12
-1
lines changed
src/Autofac/Features/OpenGenerics
test/Autofac.Test/Features/OpenGenerics
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ public static bool TryBindServiceType(
44
44
out Service [ ] constructedServices )
45
45
{
46
46
var swt = service as IServiceWithType ;
47
- if ( swt != null && swt . ServiceType . GetTypeInfo ( ) . IsGenericType )
47
+ if ( swt != null && swt . ServiceType . GetTypeInfo ( ) . IsGenericType && ! swt . ServiceType . IsGenericTypeDefinition )
48
48
{
49
49
var definitionService = ( IServiceWithType ) swt . ChangeType ( swt . ServiceType . GetGenericTypeDefinition ( ) ) ;
50
50
var serviceGenericArguments = swt . ServiceType . GetTypeInfo ( ) . GenericTypeArguments ;
Original file line number Diff line number Diff line change @@ -341,6 +341,17 @@ public void ResolveTypeFromOpenGenericInterfaceTypeParameterIsInterfaceWithConst
341
341
var instance = container . Resolve < INested < ISimpleInterface > > ( ) ;
342
342
}
343
343
344
+ [ Fact ]
345
+ public void CheckGenericTypeIsRegisteredWhenNotSpecifyParameterType ( )
346
+ {
347
+ // Issue #1040: IsRegistered throws IndexOutOfRangeException for open generic type
348
+ var cb = new ContainerBuilder ( ) ;
349
+ cb . RegisterGeneric ( typeof ( C < > ) ) ;
350
+ var container = cb . Build ( ) ;
351
+
352
+ Assert . False ( container . IsRegistered ( typeof ( C < > ) ) ) ;
353
+ }
354
+
344
355
private class CNestedSimpleInterface : INested < ISimpleInterface >
345
356
{
346
357
}
You can’t perform that action at this time.
0 commit comments