File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -8,13 +8,14 @@ namespace JsonApiDotNetCore
88{
99 internal sealed class CollectionConverter
1010 {
11- private static readonly Type [ ] HashSetCompatibleCollectionTypes =
11+ private static readonly ISet < Type > HashSetCompatibleCollectionTypes = new HashSet < Type >
1212 {
1313 typeof ( HashSet < > ) ,
14- typeof ( ICollection < > ) ,
1514 typeof ( ISet < > ) ,
16- typeof ( IEnumerable < > ) ,
17- typeof ( IReadOnlyCollection < > )
15+ typeof ( IReadOnlySet < > ) ,
16+ typeof ( ICollection < > ) ,
17+ typeof ( IReadOnlyCollection < > ) ,
18+ typeof ( IEnumerable < > )
1819 } ;
1920
2021 /// <summary>
@@ -49,15 +50,14 @@ public Type ToConcreteCollectionType(Type collectionType)
4950 {
5051 if ( collectionType . IsInterface && collectionType . IsGenericType )
5152 {
52- Type genericTypeDefinition = collectionType . GetGenericTypeDefinition ( ) ;
53+ Type openCollectionType = collectionType . GetGenericTypeDefinition ( ) ;
5354
54- if ( genericTypeDefinition == typeof ( ICollection < > ) || genericTypeDefinition == typeof ( ISet < > ) ||
55- genericTypeDefinition == typeof ( IEnumerable < > ) || genericTypeDefinition == typeof ( IReadOnlyCollection < > ) )
55+ if ( HashSetCompatibleCollectionTypes . Contains ( openCollectionType ) )
5656 {
5757 return typeof ( HashSet < > ) . MakeGenericType ( collectionType . GenericTypeArguments [ 0 ] ) ;
5858 }
5959
60- if ( genericTypeDefinition == typeof ( IList < > ) || genericTypeDefinition == typeof ( IReadOnlyList < > ) )
60+ if ( openCollectionType == typeof ( IList < > ) || openCollectionType == typeof ( IReadOnlyList < > ) )
6161 {
6262 return typeof ( List < > ) . MakeGenericType ( collectionType . GenericTypeArguments [ 0 ] ) ;
6363 }
You can’t perform that action at this time.
0 commit comments