@@ -32,7 +32,7 @@ public class JsonTypeMigrationConverter : JsonConverter<object>
3232 /// To add migrations, call the <see cref="AddTypeMigration"/> method.
3333 /// </remarks>
3434 public JsonTypeMigrationConverter ( )
35- : this ( null )
35+ : this ( Array . Empty < JsonTypeMigration > ( ) )
3636 {
3737 }
3838
@@ -42,7 +42,7 @@ public JsonTypeMigrationConverter()
4242 /// <param name="migrations">The type migrations to initialize with.</param>
4343 public JsonTypeMigrationConverter ( params JsonTypeMigration [ ] migrations )
4444 {
45- if ( migrations != null && migrations . Any ( ) )
45+ if ( migrations != null && migrations . Length > 0 )
4646 {
4747 this . migrations . AddRange ( migrations ) ;
4848 }
@@ -60,7 +60,7 @@ public void AddTypeMigration(JsonTypeMigration migration)
6060
6161 lock ( this . migrationLock )
6262 {
63- JsonTypeMigration existingMigration = this . migrations . FirstOrDefault (
63+ JsonTypeMigration ? existingMigration = this . migrations . FirstOrDefault (
6464 m =>
6565 m . FromAssemblyName == migration . FromAssemblyName &&
6666 m . FromTypeName == migration . FromTypeName ) ;
@@ -85,11 +85,14 @@ public override object Read(ref Utf8JsonReader reader, Type typeToConvert, JsonS
8585
8686 if ( root . ValueKind == JsonValueKind . Object && root . TryGetProperty ( "$type" , out JsonElement typeElement ) )
8787 {
88- string typeString = typeElement . GetString ( ) ;
89- resolvedType = this . ResolveType ( typeString ) ?? typeToConvert ;
88+ string ? typeString = typeElement . GetString ( ) ;
89+ if ( typeString != null )
90+ {
91+ resolvedType = this . ResolveType ( typeString ) ?? typeToConvert ;
92+ }
9093 }
9194
92- return root . Deserialize ( resolvedType , this . GetInnerOptions ( options ) ) ;
95+ return root . Deserialize ( resolvedType , this . GetInnerOptions ( options ) ) ! ;
9396 }
9497
9598 /// <inheritdoc/>
@@ -110,13 +113,13 @@ private JsonSerializerOptions GetInnerOptions(JsonSerializerOptions options)
110113 return this . innerOptions ;
111114 }
112115
113- private Type ResolveType ( string typeString )
116+ private Type ? ResolveType ( string typeString )
114117 {
115118 int commaIndex = typeString . IndexOf ( ',' ) ;
116119 string typeName = commaIndex >= 0 ? typeString [ ..commaIndex ] . Trim ( ) : typeString . Trim ( ) ;
117- string assemblyName = commaIndex >= 0 ? typeString [ ( commaIndex + 1 ) ..] . Trim ( ) : null ;
120+ string ? assemblyName = commaIndex >= 0 ? typeString [ ( commaIndex + 1 ) ..] . Trim ( ) : null ;
118121
119- JsonTypeMigration migration ;
122+ JsonTypeMigration ? migration ;
120123 lock ( this . migrationLock )
121124 {
122125 migration = this . migrations . FirstOrDefault (
0 commit comments