File tree 1 file changed +8
-8
lines changed
1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -8,13 +8,14 @@ namespace JsonApiDotNetCore
8
8
{
9
9
internal sealed class CollectionConverter
10
10
{
11
- private static readonly Type [ ] HashSetCompatibleCollectionTypes =
11
+ private static readonly ISet < Type > HashSetCompatibleCollectionTypes = new HashSet < Type >
12
12
{
13
13
typeof ( HashSet < > ) ,
14
- typeof ( ICollection < > ) ,
15
14
typeof ( ISet < > ) ,
16
- typeof ( IEnumerable < > ) ,
17
- typeof ( IReadOnlyCollection < > )
15
+ typeof ( IReadOnlySet < > ) ,
16
+ typeof ( ICollection < > ) ,
17
+ typeof ( IReadOnlyCollection < > ) ,
18
+ typeof ( IEnumerable < > )
18
19
} ;
19
20
20
21
/// <summary>
@@ -49,15 +50,14 @@ public Type ToConcreteCollectionType(Type collectionType)
49
50
{
50
51
if ( collectionType . IsInterface && collectionType . IsGenericType )
51
52
{
52
- Type genericTypeDefinition = collectionType . GetGenericTypeDefinition ( ) ;
53
+ Type openCollectionType = collectionType . GetGenericTypeDefinition ( ) ;
53
54
54
- if ( genericTypeDefinition == typeof ( ICollection < > ) || genericTypeDefinition == typeof ( ISet < > ) ||
55
- genericTypeDefinition == typeof ( IEnumerable < > ) || genericTypeDefinition == typeof ( IReadOnlyCollection < > ) )
55
+ if ( HashSetCompatibleCollectionTypes . Contains ( openCollectionType ) )
56
56
{
57
57
return typeof ( HashSet < > ) . MakeGenericType ( collectionType . GenericTypeArguments [ 0 ] ) ;
58
58
}
59
59
60
- if ( genericTypeDefinition == typeof ( IList < > ) || genericTypeDefinition == typeof ( IReadOnlyList < > ) )
60
+ if ( openCollectionType == typeof ( IList < > ) || openCollectionType == typeof ( IReadOnlyList < > ) )
61
61
{
62
62
return typeof ( List < > ) . MakeGenericType ( collectionType . GenericTypeArguments [ 0 ] ) ;
63
63
}
You can’t perform that action at this time.
0 commit comments