@@ -284,7 +284,19 @@ private static bool ListParamTypeIsValid(Type listType, FillerSetupItem currentS
284284 /// </returns>
285285 private static bool TypeIsDictionary ( Type type )
286286 {
287- return type . GetImplementedInterfaces ( ) . Any ( x => x == typeof ( IDictionary ) ) ;
287+ Type interfaceType = typeof ( IDictionary ) ;
288+ Type genericType = typeof ( IDictionary < , > ) ;
289+
290+ if ( type . IsInterface ( ) )
291+ {
292+ return type . IsGenericType ( ) &&
293+ (
294+ type . GetGenericTypeDefinition ( ) == genericType ||
295+ type . GetImplementedInterfaces ( ) . Any ( x => x . IsGenericType ( ) && x . GetGenericTypeDefinition ( ) == typeof ( IDictionary < , > ) )
296+ ) ;
297+ }
298+
299+ return type . GetImplementedInterfaces ( ) . Any ( x => x == interfaceType ) ;
288300 }
289301
290302 /// <summary>
@@ -751,7 +763,6 @@ private IDictionary GetFilledDictionary(
751763 FillerSetupItem currentSetupItem ,
752764 HashStack < Type > typeTracker )
753765 {
754- IDictionary dictionary = ( IDictionary ) Activator . CreateInstance ( propertyType ) ;
755766
756767 bool derivedType = ! propertyType. GetGenericTypeArguments( ) . Any ( ) ;
757768
@@ -763,6 +774,24 @@ private IDictionary GetFilledDictionary(
763774 ? propertyType . GetGenericTypeArguments ( ) [ 1 ]
764775 : propertyType . GetTypeInfo ( ) . BaseType . GetGenericTypeArguments ( ) [ 1 ] ;
765776
777+ IDictionary dictionary;
778+ if ( ! propertyType . IsInterface ( )
779+ && propertyType . GetImplementedInterfaces ( ) . Any ( x => x == typeof ( IDictionary ) ) )
780+ {
781+ dictionary = ( IDictionary) Activator. CreateInstance( propertyType) ;
782+ }
783+ else if ( propertyType. IsGenericType( ) && propertyType. GetGenericTypeDefinition( ) == typeof ( IDictionary< , > )
784+ || propertyType. GetImplementedInterfaces( ) . Any( x => x. IsGenericType( ) && x. GetGenericTypeDefinition( ) == typeof ( IDictionary< , > ) ) )
785+ {
786+ Type openDictionaryType = typeof ( Dictionary< , > ) ;
787+ Type genericDictionaryType = openDictionaryType. MakeGenericType( keyType, valueType) ;
788+ dictionary = ( IDictionary) Activator. CreateInstance( genericDictionaryType) ;
789+ }
790+ else
791+ {
792+ dictionary = ( IDictionary) Activator. CreateInstance( propertyType) ;
793+ }
794+
766795 int maxDictionaryItems = 0 ;
767796
768797 if ( keyType. IsEnum( ) )
0 commit comments