AspNetCore.Diagnostics.HealthChecks
AspNetCore.Diagnostics.HealthChecks copied to clipboard
NativeAOT support for UiResponseWriter
What happened: An exception was thrown: System.InvalidOperationException: Reflection-based serialization has been disabled for this application. Either use the source generator APIs or explicitly configure the 'JsonSerializerOptions.TypeInfoResolver' property.
What you expected to happen: a healthy response json.
How to reproduce it (as minimally and precisely as possible):
- Create a NativeAOT WebApi project
- Add AspNetCore.HealthChecks.UI.Client
- Add the Writer;
- I also used AspNetCore.HealthChecks.ApplicationStatus, but I would say It does not matter which ones you use, as the issue lies within the Writer file.
- start the application and call the health endpoint.
Source code sample:
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
var builder = WebApplication.CreateSlimBuilder(args);
builder.Services
.AddHealthChecks()
.AddApplicationStatus();
builder.Services.AddInfrastructure();
var app = builder.Build();
app.MapHealthChecks("/_health", new HealthCheckOptions {ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse});
await app.RunAsync();
Anything else we need to know?:
Environment:
- .NET Core version: 8.0.0
- Healthchecks version: 8.0.0
- Operative system: Windows 10
- Others: