@@ -33,7 +33,11 @@ public class Command
3333 {
3434 private readonly static JsonSerializerOptions s_jsonSerializerOptions = new ( )
3535 {
36- TypeInfoResolver = JsonTypeInfoResolver . Combine ( CommandJsonSerializerContext . Default , new DefaultJsonTypeInfoResolver ( ) ) ,
36+ TypeInfoResolverChain =
37+ {
38+ CommandJsonSerializerContext . Default ,
39+ new DefaultJsonTypeInfoResolver ( )
40+ } ,
3741 Converters = { new ResponseValueJsonConverter ( ) }
3842 } ;
3943
@@ -86,17 +90,14 @@ public string ParametersAsJsonString
8690 {
8791 get
8892 {
89- string parametersString ;
9093 if ( this . Parameters != null && this . Parameters . Count > 0 )
9194 {
92- parametersString = JsonSerializer . Serialize ( this . Parameters , s_jsonSerializerOptions ) ;
95+ return JsonSerializer . Serialize ( this . Parameters , s_jsonSerializerOptions ) ;
9396 }
9497 else
9598 {
96- parametersString = "{}" ;
99+ return "{}" ;
97100 }
98-
99- return parametersString ;
100101 }
101102 }
102103
@@ -118,7 +119,7 @@ public override string ToString()
118119 /// <exception cref="ArgumentNullException">If <paramref name="value"/> is <see langword="null"/>.</exception>
119120 private static Dictionary < string , object ? > ? ConvertParametersFromJson ( string value )
120121 {
121- Dictionary < string , object ? > ? parameters = JsonSerializer . Deserialize < Dictionary < string , object ? > > ( value , s_jsonSerializerOptions ) ;
122+ Dictionary < string , object ? > ? parameters = JsonSerializer . Deserialize < Dictionary < string , object ? > > ( value , CommandJsonSerializerContext . Default . DictionaryStringObject ! ) ;
122123 return parameters ;
123124 }
124125 }
@@ -167,5 +168,6 @@ public override string ToString()
167168 [ JsonSerializable ( typeof ( Dictionary < string , short > ) ) ]
168169 [ JsonSerializable ( typeof ( Dictionary < string , ushort > ) ) ]
169170 [ JsonSerializable ( typeof ( Dictionary < string , string > ) ) ]
171+ [ JsonSourceGenerationOptions ( Converters = [ typeof ( ResponseValueJsonConverter ) ] ) ]
170172 internal partial class CommandJsonSerializerContext : JsonSerializerContext ;
171173}
0 commit comments