Skip to content

Commit ff1a125

Browse files
committed
add status property deserialization
1 parent 62fc1d3 commit ff1a125

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Extensions.Microsoft.Diagnostics.HealthChecks.Serialization/src/HealthReportConverter.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public override HealthReport Read(ref Utf8JsonReader reader, Type typeToConvert,
1515
var healthReportOptions = HealthReportJsonSerializerOptionsFactory.Create(options);
1616
Dictionary<string, HealthReportEntry>? entries = null;
1717
var totalDuration = TimeSpan.Zero;
18+
HealthStatus? status = null;
1819

1920
while (reader.Read() && reader.TokenType != JsonTokenType.EndObject)
2021
{
@@ -25,6 +26,11 @@ public override HealthReport Read(ref Utf8JsonReader reader, Type typeToConvert,
2526

2627
switch (healthReportOptions.PropertyNameCaseInsensitive ? propertyName : propertyName?.ToLowerInvariant())
2728
{
29+
case "Status":
30+
case "status":
31+
status = JsonSerializer.Deserialize<HealthStatus>(ref reader, healthReportOptions);
32+
break;
33+
2834
case "TotalDuration":
2935
case "totalDuration":
3036
case "totalduration":
@@ -39,7 +45,11 @@ public override HealthReport Read(ref Utf8JsonReader reader, Type typeToConvert,
3945
}
4046
}
4147

42-
return new HealthReport(entries ?? new(), totalDuration);
48+
var report = status is null
49+
? new HealthReport(entries ?? new(), totalDuration)
50+
: new HealthReport(entries ?? new(), status.Value, totalDuration);
51+
52+
return report;
4353
}
4454

4555
public override void Write(Utf8JsonWriter writer, HealthReport value, JsonSerializerOptions options)

0 commit comments

Comments
 (0)