Hlibz.UseCases
1.0.0
See the version list below for details.
dotnet add package Hlibz.UseCases --version 1.0.0
NuGet\Install-Package Hlibz.UseCases -Version 1.0.0
<PackageReference Include="Hlibz.UseCases" Version="1.0.0" />
<PackageVersion Include="Hlibz.UseCases" Version="1.0.0" />
<PackageReference Include="Hlibz.UseCases" />
paket add Hlibz.UseCases --version 1.0.0
#r "nuget: Hlibz.UseCases, 1.0.0"
#:package Hlibz.UseCases@1.0.0
#addin nuget:?package=Hlibz.UseCases&version=1.0.0
#tool nuget:?package=Hlibz.UseCases&version=1.0.0
![]()
Hlibz.UseCases
Use cases for .NET apps with more than one client: HTTP endpoints, MCP tools, gRPC services and jobs all call the same handler, and every rule lives in the use case, validation included, written as DataAnnotations on the use case record.
dotnet add package Hlibz.UseCases
public sealed record CreateCityCommand(
[Required, MaxLength(60)] string Name,
[Range(1, 50_000_000)] int Population) : IUseCase;
public interface ICreateCityCommandHandler : IUseCaseHandler<CreateCityCommand, CityDto>;
internal sealed class CreateCityCommandHandler(AtlasDbContext db) : ICreateCityCommandHandler
{
public async Task<Result<CityDto>> HandleAsync(CreateCityCommand useCase, CancellationToken cancellationToken = default)
{
... // only valid use cases get here
}
}
builder.Services.AddUseCases([typeof(CreateCityCommand).Assembly]);
builder.Services.AddUseCaseFilter<AuditFilter>(); // optional: runs for every use case
app.MapPost("cities", async (CreateCityCommand command, ICreateCityCommandHandler handler, CancellationToken ct) =>
(await handler.HandleAsync(command, ct)).ToHttpResult());
- A source generator lists the handlers at compile time (no assembly scan) and wraps each one
in a pipeline: validation, your
IUseCaseFilters, the handler. Clients inject the handler's own interface; there is no mediator. - Validation without ASP.NET Core that fails exactly as ASP.NET Core's
AddValidation()does: record parameter attributes, nested objects and collection items (Costs[0].Value),IValidatableObject, async rules on .NET 11. An invalid use case returnsResult.InvalidwithValidationErrorsand never reaches the handler. - Rules that describe themselves:
IDescribedRuleand[RuleSummary]say what a custom rule checks, shaped like JSON Schema, for an OpenAPI document or a tool schema to publish. - A handler it can't register is a build error (
HUC001-HUC007).
Targets .NET 10 and 11. Full documentation: github.com/hlib-zinchenko/Hlibz.UseCases.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- Hlibz.Results (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
-
net11.0
- Hlibz.Results (>= 2.2.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Hlibz.UseCases:
| Package | Downloads |
|---|---|
|
Hlibz.OpenApi.UseCases
Publishes Hlibz.UseCases in OpenAPI documents built with Microsoft.AspNetCore.OpenApi: the rules use cases describe (IDescribedRule, [RuleSummary]) as schema keywords and text, DataAnnotations on record constructor parameters, and the 400 of the operations whose use case can fail validation. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0-preview.2 | 0 | 11/27/2026 |
| 2.0.0-preview.1 | 0 | 11/27/2026 |
| 1.0.0 | 92 | 11/25/2026 |
| 1.0.0-preview.2 | 60 | 11/23/2026 |
| 1.0.0-preview.1 | 79 | 11/22/2026 |