@@ -118,39 +118,39 @@ public JsonDictionaryContract(Type underlyingType)
118
118
Type ? keyType ;
119
119
Type ? valueType ;
120
120
121
- if ( ReflectionUtils . ImplementsGenericDefinition ( underlyingType , typeof ( IDictionary < , > ) , out _genericCollectionDefinitionType ) )
121
+ if ( ReflectionUtils . ImplementsGenericDefinition ( NonNullableUnderlyingType , typeof ( IDictionary < , > ) , out _genericCollectionDefinitionType ) )
122
122
{
123
123
keyType = _genericCollectionDefinitionType . GetGenericArguments ( ) [ 0 ] ;
124
124
valueType = _genericCollectionDefinitionType . GetGenericArguments ( ) [ 1 ] ;
125
125
126
- if ( ReflectionUtils . IsGenericDefinition ( UnderlyingType , typeof ( IDictionary < , > ) ) )
126
+ if ( ReflectionUtils . IsGenericDefinition ( NonNullableUnderlyingType , typeof ( IDictionary < , > ) ) )
127
127
{
128
128
CreatedType = typeof ( Dictionary < , > ) . MakeGenericType ( keyType , valueType ) ;
129
129
}
130
- else if ( underlyingType . IsGenericType ( ) )
130
+ else if ( NonNullableUnderlyingType . IsGenericType ( ) )
131
131
{
132
132
// ConcurrentDictionary<,> + IDictionary setter + null value = error
133
133
// wrap to use generic setter
134
134
// https://github.com/JamesNK/Newtonsoft.Json/issues/1582
135
- Type typeDefinition = underlyingType . GetGenericTypeDefinition ( ) ;
135
+ Type typeDefinition = NonNullableUnderlyingType . GetGenericTypeDefinition ( ) ;
136
136
if ( typeDefinition . FullName == JsonTypeReflector . ConcurrentDictionaryTypeName )
137
137
{
138
138
ShouldCreateWrapper = true ;
139
139
}
140
140
}
141
141
142
142
#if HAVE_READ_ONLY_COLLECTIONS
143
- IsReadOnlyOrFixedSize = ReflectionUtils . InheritsGenericDefinition ( underlyingType , typeof ( ReadOnlyDictionary < , > ) ) ;
143
+ IsReadOnlyOrFixedSize = ReflectionUtils . InheritsGenericDefinition ( NonNullableUnderlyingType , typeof ( ReadOnlyDictionary < , > ) ) ;
144
144
#endif
145
145
146
146
}
147
147
#if HAVE_READ_ONLY_COLLECTIONS
148
- else if ( ReflectionUtils . ImplementsGenericDefinition ( underlyingType , typeof ( IReadOnlyDictionary < , > ) , out _genericCollectionDefinitionType ) )
148
+ else if ( ReflectionUtils . ImplementsGenericDefinition ( NonNullableUnderlyingType , typeof ( IReadOnlyDictionary < , > ) , out _genericCollectionDefinitionType ) )
149
149
{
150
150
keyType = _genericCollectionDefinitionType . GetGenericArguments ( ) [ 0 ] ;
151
151
valueType = _genericCollectionDefinitionType . GetGenericArguments ( ) [ 1 ] ;
152
152
153
- if ( ReflectionUtils . IsGenericDefinition ( UnderlyingType , typeof ( IReadOnlyDictionary < , > ) ) )
153
+ if ( ReflectionUtils . IsGenericDefinition ( NonNullableUnderlyingType , typeof ( IReadOnlyDictionary < , > ) ) )
154
154
{
155
155
CreatedType = typeof ( ReadOnlyDictionary < , > ) . MakeGenericType ( keyType , valueType ) ;
156
156
}
@@ -160,9 +160,9 @@ public JsonDictionaryContract(Type underlyingType)
160
160
#endif
161
161
else
162
162
{
163
- ReflectionUtils . GetDictionaryKeyValueTypes ( UnderlyingType , out keyType , out valueType ) ;
163
+ ReflectionUtils . GetDictionaryKeyValueTypes ( NonNullableUnderlyingType , out keyType , out valueType ) ;
164
164
165
- if ( UnderlyingType == typeof ( IDictionary ) )
165
+ if ( NonNullableUnderlyingType == typeof ( IDictionary ) )
166
166
{
167
167
CreatedType = typeof ( Dictionary < object , object > ) ;
168
168
}
@@ -176,9 +176,9 @@ public JsonDictionaryContract(Type underlyingType)
176
176
typeof ( IDictionary < , > ) . MakeGenericType ( keyType , valueType ) ) ;
177
177
178
178
#if HAVE_FSHARP_TYPES
179
- if ( ! HasParameterizedCreatorInternal && underlyingType . Name == FSharpUtils . FSharpMapTypeName )
179
+ if ( ! HasParameterizedCreatorInternal && NonNullableUnderlyingType . Name == FSharpUtils . FSharpMapTypeName )
180
180
{
181
- FSharpUtils . EnsureInitialized ( underlyingType . Assembly ( ) ) ;
181
+ FSharpUtils . EnsureInitialized ( NonNullableUnderlyingType . Assembly ( ) ) ;
182
182
_parameterizedCreator = FSharpUtils . Instance . CreateMap ( keyType , valueType ) ;
183
183
}
184
184
#endif
@@ -207,7 +207,7 @@ public JsonDictionaryContract(Type underlyingType)
207
207
if ( DictionaryKeyType != null &&
208
208
DictionaryValueType != null &&
209
209
ImmutableCollectionsUtils . TryBuildImmutableForDictionaryContract (
210
- underlyingType ,
210
+ NonNullableUnderlyingType ,
211
211
DictionaryKeyType ,
212
212
DictionaryValueType ,
213
213
out Type ? immutableCreatedType ,
0 commit comments