@@ -6,15 +6,6 @@ namespace HydraScript.Domain.BackEnd.Impl.Instructions.WithAssignment;
66
77public partial class AsString ( IValue value ) : Simple ( value )
88{
9- private static readonly AsStringSerializationContext AsStringJsonContext = new ( new JsonSerializerOptions
10- {
11- WriteIndented = true ,
12- ReferenceHandler = ReferenceHandler . IgnoreCycles ,
13- PropertyNamingPolicy = JsonNamingPolicy . CamelCase ,
14- NumberHandling = JsonNumberHandling . AllowNamedFloatingPointLiterals ,
15- Encoder = JavaScriptEncoder . UnsafeRelaxedJsonEscaping
16- } ) ;
17-
189 public override IAddress ? Execute ( IExecuteParams executeParams )
1910 {
2011 var frame = executeParams . Frames . Peek ( ) ;
@@ -23,20 +14,35 @@ public partial class AsString(IValue value) : Simple(value)
2314 ? value
2415 : JsonSerializer . Serialize (
2516 value : Right . right ! . Get ( frame ) ! ,
26- AsStringJsonContext . Object ) ;
17+ AsStringSerializationContext . Default . Object ) ;
2718
2819 return Address . Next ;
2920 }
3021
3122 protected override string ToStringInternal ( ) =>
3223 $ "{ Left } = { Right . right } as string";
3324
34- [ JsonSourceGenerationOptions ( GenerationMode = JsonSourceGenerationMode . Serialization ) ]
25+ [ JsonSourceGenerationOptions (
26+ GenerationMode = JsonSourceGenerationMode . Serialization ,
27+ PropertyNamingPolicy = JsonKnownNamingPolicy . CamelCase ,
28+ NumberHandling = JsonNumberHandling . AllowNamedFloatingPointLiterals ,
29+ ReferenceHandler = JsonKnownReferenceHandler . IgnoreCycles ,
30+ WriteIndented = true ) ]
3531 [ JsonSerializable ( typeof ( List < object > ) ) ]
3632 [ JsonSerializable ( typeof ( Dictionary < string , object > ) ) ]
3733 [ JsonSerializable ( typeof ( bool ) ) ]
3834 [ JsonSerializable ( typeof ( double ) ) ]
3935 [ JsonSerializable ( typeof ( string ) ) ]
4036 [ JsonSerializable ( typeof ( int ) ) ]
41- private partial class AsStringSerializationContext : JsonSerializerContext ;
37+ private sealed partial class AsStringSerializationContext : JsonSerializerContext
38+ {
39+ static AsStringSerializationContext ( )
40+ {
41+ Default = new AsStringSerializationContext (
42+ new JsonSerializerOptions ( Default . GeneratedSerializerOptions ! )
43+ {
44+ Encoder = JavaScriptEncoder . UnsafeRelaxedJsonEscaping
45+ } ) ;
46+ }
47+ }
4248}
0 commit comments