Skip to content

Commit

Permalink
fixup! json: use source generation for JSON serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
mjcheetham committed Sep 22, 2023
1 parent 5bad1be commit 4fa39ba
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/shared/Core/Trace2Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,26 @@

namespace GitCredentialManager;

public class JsonSnakeCaseEnumConverter : JsonStringEnumConverter
public class Trace2EventEnumConverter : JsonStringEnumConverter<Trace2Event>
{
public JsonSnakeCaseEnumConverter()
public Trace2EventEnumConverter()
: base(JsonNamingPolicy.SnakeCaseLower, false) { }
}

public class Trace2ProcessClassEnumConverter : JsonStringEnumConverter<Trace2ProcessClass>
{
public Trace2ProcessClassEnumConverter()
: base(JsonNamingPolicy.SnakeCaseLower, false) { }
}

[JsonSourceGenerationOptions(
PropertyNamingPolicy = JsonKnownNamingPolicy.SnakeCaseLower,
PropertyNameCaseInsensitive = true,
Converters = new[] { typeof(JsonSnakeCaseEnumConverter) }
Converters = new[]
{
typeof(Trace2EventEnumConverter),
typeof(Trace2ProcessClassEnumConverter)
}
)]
[JsonSerializable(typeof(VersionMessage))]
[JsonSerializable(typeof(StartMessage))]
Expand Down

0 comments on commit 4fa39ba

Please sign in to comment.