@@ -9,13 +9,12 @@ namespace StructId;
99
1010public static partial class StructIdConverters
1111{
12- #if NET7_0_OR_GREATER
13- public class SystemTextJsonConverter < TSelf , TValue > : JsonConverter < TSelf >
14- where TSelf : IStructId < TValue > , INewable < TSelf , TValue >
15- where TValue : struct , IParsable < TValue >
12+ public class SystemTextJsonConverter < TSelf , TId > : JsonConverter < TSelf >
13+ where TSelf : IStructId < TId > , INewable < TSelf , TId >
14+ where TId : struct , IParsable < TId >
1615 {
1716 public override TSelf Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
18- => TSelf . New ( TValue . Parse ( reader . GetString ( ) ?? throw new FormatException ( "Unsupported null value for struct id." ) , CultureInfo . InvariantCulture ) ) ;
17+ => TSelf . New ( TId . Parse ( reader . GetString ( ) ?? throw new FormatException ( "Unsupported null value for struct id." ) , CultureInfo . InvariantCulture ) ) ;
1918
2019 public override void Write ( Utf8JsonWriter writer , TSelf value , JsonSerializerOptions options )
2120 {
@@ -24,7 +23,7 @@ public override void Write(Utf8JsonWriter writer, TSelf value, JsonSerializerOpt
2423 case Guid guid :
2524 writer . WriteStringValue ( guid ) ;
2625 break ;
27- case TValue inner :
26+ case TId inner :
2827 writer . WriteRawValue ( inner . ToString ( ) ) ;
2928 break ;
3029 default :
@@ -33,7 +32,7 @@ public override void Write(Utf8JsonWriter writer, TSelf value, JsonSerializerOpt
3332 }
3433
3534 public override TSelf ReadAsPropertyName ( ref global ::System . Text . Json . Utf8JsonReader reader , global ::System . Type typeToConvert , global ::System . Text . Json . JsonSerializerOptions options )
36- => TSelf . New ( TValue . Parse ( reader . GetString ( ) ?? throw new FormatException ( "Unsupported null value for struct id." ) , CultureInfo . InvariantCulture ) ) ;
35+ => TSelf . New ( TId . Parse ( reader . GetString ( ) ?? throw new FormatException ( "Unsupported null value for struct id." ) , CultureInfo . InvariantCulture ) ) ;
3736
3837 public override void WriteAsPropertyName ( global ::System . Text . Json . Utf8JsonWriter writer , TSelf value , global ::System . Text . Json . JsonSerializerOptions options )
3938 => writer . WritePropertyName ( value . Value . ToString ( ) ) ;
@@ -54,5 +53,4 @@ public override TSelf ReadAsPropertyName(ref global::System.Text.Json.Utf8JsonRe
5453 public override void WriteAsPropertyName ( global ::System . Text . Json . Utf8JsonWriter writer , TSelf value , global ::System . Text . Json . JsonSerializerOptions options )
5554 => writer . WritePropertyName ( value . Value ) ;
5655 }
57- #endif
5856}
0 commit comments