All other properties (`Predicate`, `ResponseWriter` and `AllowCachingResponses`) have a setter but `ResultStatusCodes` doesn't.
Without a setter, reusing the same status to http status code mapping is impossible and leads to duplicate code that looks like this:
```csharp
private static void ConfigureHealthChecks(IApplicationBuilder app, HealthCheckServiceOptions options)
{
app.UseHealthChecks("/health", new HealthCheckOptions
{
ResultStatusCodes =
{
[HealthStatus.Healthy] = StatusCodes.Status200OK,
[HealthStatus.Degraded] = StatusCodes.Status400BadRequest,
[HealthStatus.Unhealthy] = StatusCodes.Status503ServiceUnavailable
}
});
foreach (var name in options.Registrations.Select(e => e.Name))
{
app.UseHealthChecks($"/health/{name}", new HealthCheckOptions
{
Predicate = registration => registration.Name == name,
ResultStatusCodes =
{
[HealthStatus.Healthy] = StatusCodes.Status200OK,
[HealthStatus.Degraded] = StatusCodes.Status400BadRequest,
[HealthStatus.Unhealthy] = StatusCodes.Status503ServiceUnavailable
}
});
}
}
```
With a setter, this code could be rewritten in a *don't repeat yourself* (DRY) way:
```csharp
private static void ConfigureHealthChecks(IApplicationBuilder app, HealthCheckServiceOptions options)
{
var resultStatusCodes = new Dictionary<HealthStatus, int>
{
[HealthStatus.Healthy] = StatusCodes.Status200OK,
[HealthStatus.Degraded] = StatusCodes.Status400BadRequest,
[HealthStatus.Unhealthy] = StatusCodes.Status503ServiceUnavailable
};
app.UseHealthChecks("/health", new HealthCheckOptions
{
ResultStatusCodes = resultStatusCodes
});
foreach (var name in options.Registrations.Select(e => e.Name))
{
app.UseHealthChecks($"/health/{name}", new HealthCheckOptions
{
Predicate = registration => registration.Name == name,
ResultStatusCodes = resultStatusCodes
});
}
}
```
* Workaround problems when opening solution files in Visual Studio (#4569)
Changes:
* Condense Routing.sln into HttpAbstractions.sln
* Workaround NU1105 by adding all ProjectReferences to the .sln
* Workaround exceptions in the ReferencesHostBridge by moving Reference items to a temporary item group
* Add a 'startvs.cmd' script for launching VS with the right env variables
* Remove RangeHelper test project
* Move RangeHelper tests into StaticFiles.Tests and add target for NPM restore
* Convert Session to use Reference and move to Middleware folder (#4576)
* Add RoutingSample.Web to HttpAbstractions.sln
Changes:
* Condense Routing.sln into HttpAbstractions.sln
* Workaround NU1105 by adding all ProjectReferences to the .sln
* Workaround exceptions in the ReferencesHostBridge by moving Reference items to a temporary item group
* Add a 'startvs.cmd' script for launching VS with the right env variables
* Remove RangeHelper test project
* Move RangeHelper tests into StaticFiles.Tests and add target for NPM restore
* Put packages back into 'ship' which were unintentionally skipped in 3.0 refactoring
* Libuv transport for kestrel
* Http connection abstractions shared by SignalR client and Kestrel.
* Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson - this wasn't moved to the right category when it was added
* Make dotnet-* packages internal-only. They were only shipped to NuGet.org because we had not yet enabled source-build. We plan to implement source-build in 3.0 (#3752)
* Make Microsoft.Extensions.Identity.* packages shared-framework only (see #4523).
* Remove unused entries for packages that moved to aspnet/AspNetCore-Tooling
* Add comments in the artifacts.props document for why each 'noship' package is in this category.