Skip to content

Releases

2.0.0

Choose a tag to compare

@hlib-zinchenko hlib-zinchenko released this 18 Nov 07:51

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.0 and net9.0 are dropped (.NET 8 and 9 reached end of support on 10 Nov 2026).
  • ErrorCodeCatalog reads a generated list of each assembly's public static ErrorCode fields 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.
  • MapErrorCodes carries ASP.NET Core's AOT warnings for mapping a delegate ([RequiresDynamicCode]/[RequiresUnreferencedCode]).

Features

  • Native AOT. IsAotCompatible is on for every package. AddResultErrorResponses() adds source-generated System.Text.Json metadata for ErrorResponse, ResultEnvelope and the error code list. The README's AOT section lists what your own JsonSerializerContext needs (each handler's Result/Result<T> and ResultEnvelope<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 UseEnvelope with EnvelopeAlwaysOk.
  • Result<T> with a value type works under Native AOT in WithResultResponses() and WithResultEnvelopes().

Packages

Full changelog: v1.1.0...v2.0.0

2.0.0-preview.4

2.0.0-preview.4 Pre-release
Pre-release

Choose a tag to compare

@hlib-zinchenko hlib-zinchenko released this 14 Nov 16:27

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 filter WithResultResponses()/WithResultEnvelopes() add, which runs on every request, the authorization result handler and MapAsync.
  • Docs: Native AOT needs each handler's Result type 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 under WithResultResponses(), which turns the result into an IResult before anything is written. Without it, every request fails with a NotSupportedException. The README's AOT section now lists Result/Result<T> alongside ResultEnvelope<T>, with an example. Checked with a published Native AOT app.

No API changes.

Packages

Full changelog: v2.0.0-preview.3...v2.0.0-preview.4

2.0.0-preview.3

2.0.0-preview.3 Pre-release
Pre-release

Choose a tag to compare

@hlib-zinchenko hlib-zinchenko released this 14 Nov 08:07

Third preview of 2.0: error codes are listed by a source generator, and the packages work under Native AOT.

Breaking changes

  • ErrorCodeCatalog reads a generated list of each assembly's public static ErrorCode fields 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.
  • MapErrorCodes carries ASP.NET Core's AOT warnings for mapping a delegate ([RequiresDynamicCode]/[RequiresUnreferencedCode]).

Fixes

  • Result<T> with a value type works under Native AOT. WithResultResponses() and WithResultEnvelopes() converted a Result<T> through a generic method made at runtime, which Native AOT can't do for a value type such as Result<int>. They now convert it without one.

Features

  • Source-generated JSON metadata. AddResultErrorResponses() adds compile-time System.Text.Json metadata for ErrorResponse, ResultEnvelope and 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 own JsonSerializerContext lists its ResultEnvelope<T> types and value types.
  • IsAotCompatible is 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

Full changelog: v2.0.0-preview.2...v2.0.0-preview.3

2.0.0-preview.2

2.0.0-preview.2 Pre-release
Pre-release

Choose a tag to compare

@hlib-zinchenko hlib-zinchenko released this 13 Nov 19:46

Second preview of 2.0.0.

Breaking changes

  • Equal error codes declared twice are a duplicate. ErrorCodeCatalog merged any two equal ErrorCode records, so two classes each declaring new("NOT_FOUND", "Not found.") were silently listed once. Now only the same instance seen twice (an alias such as public 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 UseEnvelope and EnvelopeAlwaysOk it 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 webapiaot template) must add ErrorResponse, ResultEnvelope and their ResultEnvelope<T> types to their JsonSerializerContext, or every error response is a 500.

Packages

Full changelog: v2.0.0-preview.1...v2.0.0-preview.2

2.0.0-preview.1

2.0.0-preview.1 Pre-release
Pre-release

Choose a tag to compare

@hlib-zinchenko hlib-zinchenko released this 13 Nov 14:48
00f09da

First preview of 2.0.0.

Breaking changes

  • .NET 10 and 11 only. net8.0 and net9.0 are dropped (.NET 8 and 9 reached end of support on 10 Nov 2026). Every package now ships net10.0 and net11.0 builds.

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.AspNetCore package 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.

Packages

Full changelog: v1.1.0...v2.0.0-preview.1

1.1.0

Choose a tag to compare

@hlib-zinchenko hlib-zinchenko released this 13 Nov 14:30

Features

  • WithResultResponses() on a minimal API endpoint or route group: handlers return a Result or Result<T> (or a Task of one) as is, with no ToHttpResult() call. Each result is sent as ToHttpResult() would send it, and the success response is documented in OpenAPI as 200 T (no body for a plain Result) instead of the inferred Result<T>.
  • WithResultEnvelopes(): the same for envelopes. Each result is sent as ToEnvelopeHttpResult() would send it and documented as 200 ResultEnvelope<T>. With your own CreateEnvelope, the 200 has 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

Choose a tag to compare

@hlib-zinchenko hlib-zinchenko released this 13 Nov 14:30

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 a ResultStatus (Success, Error, Invalid, NotFound, Unauthorized, Forbidden, Conflict, Unavailable), machine-readable ErrorCodes, Map / MapAsync / Bind, and ErrorCodeCatalog, which lists every code and fails on duplicates. No dependencies.
  • Hlibz.Results.AspNetCore: ToHttpResult() for minimal APIs and ToActionResult() for controllers, all sending one ErrorResponse body (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 WriteErrorAsync use the same body.
    • AddErrorCodeCatalog and MapErrorCodes publish your codes, with one catalog per app if you need several.
    • An opt-in envelope (ToEnvelopeHttpResult() / ToEnvelopeActionResult()), your own envelope shape through CreateEnvelope, and EnvelopeAlwaysOk.
  • Hlibz.Results.FluentValidation: ToErrorResult() / ToInvalidResult() / ToErrors() on a FluentValidation ValidationResult. 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.

Packages