Repository navigation
Releases
2.0.0
Hlibz.Results 2.0.0: .NET 10 and 11 only, error codes listed by a source generator, and Native AOT support. Same code as 2.0.0-preview.4. This summarizes the changes since 1.1.0.
Breaking changes
- .NET 10 and 11 only.
net8.0andnet9.0are dropped (.NET 8 and 9 reached end of support on 10 Nov 2026). ErrorCodeCatalogreads a generated list of each assembly's public staticErrorCodefields and properties instead of scanning its types. It throws for an assembly that references Hlibz.Results but wasn't compiled with the generator, which ships in the Hlibz.Results package (and reaches projects that get it indirectly). Dynamic (Reflection.Emit) assemblies are still scanned.- Equal error codes declared twice are a duplicate. Only the same instance seen twice (an alias) is merged. Separate declarations of the same code now fail validation.
- New warning HRES001: an error code in a private or protected nested class, which the generated list can't name.
MapErrorCodescarries ASP.NET Core's AOT warnings for mapping a delegate ([RequiresDynamicCode]/[RequiresUnreferencedCode]).
Features
- Native AOT.
IsAotCompatibleis on for every package.AddResultErrorResponses()adds source-generated System.Text.Json metadata forErrorResponse,ResultEnvelopeand the error code list. The README's AOT section lists what your ownJsonSerializerContextneeds (each handler'sResult/Result<T>andResultEnvelope<T>types). - Runtime async on .NET 11. The net11.0 build compiles its async methods with runtime async.
Fixes
- Sign-in redirects stay redirects. The authorization gate writes its error body only when the response is a 401 or 403. Before, a cookie scheme's 302 got a JSON body, or became a 200 under
UseEnvelopewithEnvelopeAlwaysOk. Result<T>with a value type works under Native AOT inWithResultResponses()andWithResultEnvelopes().
Packages
Full changelog: v1.1.0...v2.0.0
2.0.0-preview.4
Fourth preview of 2.0: built with runtime async on .NET 11, and the Native AOT docs are complete.
Changes
- Runtime async on .NET 11. The net11.0 build compiles its async methods with runtime async (
runtime-async=on), the way the .NET 11 libraries themselves are compiled: no compiler state machine, cheaper suspension inside ASP.NET Core's own async chains, and clearer async stack traces. The net10.0 build is unchanged. It covers the endpoint filterWithResultResponses()/WithResultEnvelopes()add, which runs on every request, the authorization result handler andMapAsync. - Docs: Native AOT needs each handler's
Resulttype in your JSON context. ASP.NET Core's generated endpoint code asks for JSON metadata for a minimal API handler's return type when it builds the endpoint, even underWithResultResponses(), which turns the result into anIResultbefore anything is written. Without it, every request fails with aNotSupportedException. The README's AOT section now listsResult/Result<T>alongsideResultEnvelope<T>, with an example. Checked with a published Native AOT app.
No API changes.
Packages
- Hlibz.Results 2.0.0-preview.4
- Hlibz.Results.AspNetCore 2.0.0-preview.4
- Hlibz.Results.FluentValidation 2.0.0-preview.4
Full changelog: v2.0.0-preview.3...v2.0.0-preview.4
2.0.0-preview.3
Third preview of 2.0: error codes are listed by a source generator, and the packages work under Native AOT.
Breaking changes
ErrorCodeCatalogreads a generated list of each assembly's public staticErrorCodefields and properties instead of scanning its types. It throws for an assembly that references Hlibz.Results but wasn't compiled with the generator. The generator ships in the Hlibz.Results package and reaches projects that get Hlibz.Results indirectly, so this happens only if something removes it. Dynamic (Reflection.Emit) assemblies are still scanned.- New warning HRES001: an error code in a private or protected nested class, which the generated list can't name, so it is left out of every catalog.
MapErrorCodescarries ASP.NET Core's AOT warnings for mapping a delegate ([RequiresDynamicCode]/[RequiresUnreferencedCode]).
Fixes
Result<T>with a value type works under Native AOT.WithResultResponses()andWithResultEnvelopes()converted aResult<T>through a generic method made at runtime, which Native AOT can't do for a value type such asResult<int>. They now convert it without one.
Features
- Source-generated JSON metadata.
AddResultErrorResponses()adds compile-time System.Text.Json metadata forErrorResponse,ResultEnvelopeand the error code list to the minimal-API and MVC JSON options. It goes after the app's own resolvers, and the app's naming policy still applies. Under AOT, the app's ownJsonSerializerContextlists itsResultEnvelope<T>types and value types. IsAotCompatibleis on for Hlibz.Results, Hlibz.Results.AspNetCore and Hlibz.Results.FluentValidation.- A new source generator and analyzer (
Hlibz.Results.Generators) ships inside Hlibz.Results.
Packages
- Hlibz.Results 2.0.0-preview.3
- Hlibz.Results.AspNetCore 2.0.0-preview.3
- Hlibz.Results.FluentValidation 2.0.0-preview.3
Full changelog: v2.0.0-preview.2...v2.0.0-preview.3
2.0.0-preview.2
Second preview of 2.0.0.
Breaking changes
- Equal error codes declared twice are a duplicate.
ErrorCodeCatalogmerged any two equalErrorCoderecords, so two classes each declaringnew("NOT_FOUND", "Not found.")were silently listed once. Now only the same instance seen twice (an alias such aspublic static readonly ErrorCode Missing = OrderErrors.NotFound;) is merged; separate declarations of the same code fail validation like any other duplicate. Declare the code once and refer to it.
Fixes
- Sign-in redirects stay redirects. The authorization gate wrote its error body after any failed challenge or forbid. With a scheme that redirects (cookie authentication: a 302 to the login or access-denied page) the 302 got a JSON body, and with
UseEnvelopeandEnvelopeAlwaysOkit became a 200 that browsers don't follow. The body is now written only when the response is a 401 or 403.
Docs
- Limitations: apps with reflection-based JSON turned off (Native AOT, the
webapiaottemplate) must addErrorResponse,ResultEnvelopeand theirResultEnvelope<T>types to theirJsonSerializerContext, or every error response is a 500.
Packages
- Hlibz.Results 2.0.0-preview.2
- Hlibz.Results.AspNetCore 2.0.0-preview.2
- Hlibz.Results.FluentValidation 2.0.0-preview.2
Full changelog: v2.0.0-preview.1...v2.0.0-preview.2
2.0.0-preview.1
First preview of 2.0.0.
Breaking changes
- .NET 10 and 11 only.
net8.0andnet9.0are dropped (.NET 8 and 9 reached end of support on 10 Nov 2026). Every package now shipsnet10.0andnet11.0builds.
No API changes since 1.1.0.
Changes
- The release workflow builds once at the tag's version and packs those binaries, so the published packages are the ones the tests ran on.
- Package validation checks that every target framework exposes the same API.
- READMEs:
- The
Hlibz.Results.AspNetCorepackage README is now a short quick start; the full documentation stays in the repository README. - New Limitations and Related packages sections.
- The error body example no longer shows
"validation_errors": null, which is never written.
- The
Packages
- Hlibz.Results 2.0.0-preview.1
- Hlibz.Results.AspNetCore 2.0.0-preview.1
- Hlibz.Results.FluentValidation 2.0.0-preview.1
Full changelog: v1.1.0...v2.0.0-preview.1
1.1.0
Features
WithResultResponses()on a minimal API endpoint or route group: handlers return aResultorResult<T>(or aTaskof one) as is, with noToHttpResult()call. Each result is sent asToHttpResult()would send it, and the success response is documented in OpenAPI as200 T(no body for a plainResult) instead of the inferredResult<T>.WithResultEnvelopes(): the same for envelopes. Each result is sent asToEnvelopeHttpResult()would send it and documented as200 ResultEnvelope<T>. With your ownCreateEnvelope, the200has no type.- Both leave other handlers alone, so they're safe on a whole group. A response another filter sends in place of the handler's (a validation failure, say) goes out as it is.
Fixes
- The test apps no longer watch
appsettings.json, which ran out of inotify instances on Linux CI.
Packages
Full changelog: v1.0.0...v1.1.0
1.0.0
First release of Hlibz.Results: a small Result pattern for .NET APIs, with error codes and one error body for every failure. Targets .NET 8, 9, 10 and 11.
Features
- Hlibz.Results:
Result/Result<T>with aResultStatus(Success,Error,Invalid,NotFound,Unauthorized,Forbidden,Conflict,Unavailable), machine-readableErrorCodes,Map/MapAsync/Bind, andErrorCodeCatalog, which lists every code and fails on duplicates. No dependencies. - Hlibz.Results.AspNetCore:
ToHttpResult()for minimal APIs andToActionResult()for controllers, all sending oneErrorResponsebody (message,code,validation_errors).- The HTTP code per status is configuration, for example 422 for
Invalid. - Validation keys follow your JSON naming policy per path segment.
- The authorization gate's own 401/403 and
WriteErrorAsyncuse the same body. AddErrorCodeCatalogandMapErrorCodespublish your codes, with one catalog per app if you need several.- An opt-in envelope (
ToEnvelopeHttpResult()/ToEnvelopeActionResult()), your own envelope shape throughCreateEnvelope, andEnvelopeAlwaysOk.
- The HTTP code per status is configuration, for example 422 for
- Hlibz.Results.FluentValidation:
ToErrorResult()/ToInvalidResult()/ToErrors()on a FluentValidationValidationResult. Works with FluentValidation 11.0.0 and later.
Samples: a minimal API shop and a controllers shop, each with a .http file for every failure.