Arc4u.Results
9.1.0
Prefix Reserved
dotnet add package Arc4u.Results --version 9.1.0
NuGet\Install-Package Arc4u.Results -Version 9.1.0
<PackageReference Include="Arc4u.Results" Version="9.1.0" />
<PackageVersion Include="Arc4u.Results" Version="9.1.0" />
<PackageReference Include="Arc4u.Results" />
paket add Arc4u.Results --version 9.1.0
#r "nuget: Arc4u.Results, 9.1.0"
#:package Arc4u.Results@9.1.0
#addin nuget:?package=Arc4u.Results&version=9.1.0
#tool nuget:?package=Arc4u.Results&version=9.1.0
Arc4u.Results
Fluent OnSuccess / OnFailed / LogIfFailed chains for FluentResults, steps that can fail (Then, EnsureNotNull, Ensure, Compensate, Recover), Match to end a chain, plus ProblemDetailError, ValidationError and a result logger, for the business layer of an Arc4u application.
Install
dotnet add package Arc4u.Results
Usage
OnSuccess and OnFailed run an action that cannot fail and return the result unchanged:
using Arc4u.Results;
using FluentResults;
Result result = await SaveAsync()
.OnSuccess(() => Console.WriteLine("Saved."))
.LogIfFailed()
.OnFailed(errors => Console.WriteLine($"{errors.Count} error(s)."));
static Task<Result> SaveAsync() => Task.FromResult(Result.Fail(ProblemDetailError.Create("Not saved.").WithStatusCode(409)));
A step that returns a result goes through Then or the other steps, which keep the errors of every step and stop at the first failure:
using Arc4u.Results;
using FluentResults;
Task<Result> UpdateAsync(Guid id, string name)
=> repository.GetByIdAsync(id) // Task<Result<Template?>>
.EnsureNotNull(() => ProblemDetailError.Create($"No template {id}.").WithStatusCode(404))
.Ensure(template => template.Rename(name)) // Result: the template is kept
.ThenAsync(template => repository.UpdateAsync(template)) // Task<Result>
.LogIfFailed();
Passing a callback that returns a result to OnSuccess or OnFailed is a compile error, because its errors would be discarded.
Match ends a chain by turning the result into another type, from the callback matching its state:
string message = await UpdateAsync(id, name)
.Match(() => "Template updated.", errors => $"Not updated: {errors.First().Message}");
Documentation
- Guide: Results and errors
- API reference: Arc4u.Results
- Source and issues: github.com/Arc4u-org/Arc4u
| 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
- Arc4u (>= 9.1.0)
- Arc4u.Diagnostics (>= 9.1.0)
- FluentResults (>= 4.0.0)
- Microsoft.Extensions.Hosting (>= 10.0.0)
-
net11.0
- Arc4u (>= 9.1.0)
- Arc4u.Diagnostics (>= 9.1.0)
- FluentResults (>= 4.0.0)
- Microsoft.Extensions.Hosting (>= 11.0.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Arc4u.Results:
| Package | Downloads |
|---|---|
|
Arc4u.AspNetCore.Results
Package used on Interface and Facade projects to return ProblemDetails based on Results. |
|
|
Arc4u.OAuth2
Package Description |
|
|
Arc4u.gRPC
Package Description |
|
|
Arc4u.FluentValidation
Package Description |
|
|
Arc4u.Data
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.1.0 | 218 | 11/18/2026 |
| 9.0.0 | 238 | 11/10/2026 |
| 9.0.0-preview46 | 143 | 11/3/2026 |
| 9.0.0-preview45 | 140 | 11/2/2026 |
| 9.0.0-preview44 | 138 | 11/1/2026 |
| 9.0.0-preview43 | 126 | 11/1/2026 |
| 9.0.0-preview42 | 132 | 10/30/2026 |
| 9.0.0-preview41 | 142 | 10/30/2026 |
| 9.0.0-preview40 | 152 | 10/27/2026 |
| 9.0.0-preview39 | 136 | 10/24/2026 |
| 9.0.0-preview38 | 188 | 10/22/2026 |
| 9.0.0-preview37 | 753 | 8/11/2026 |
| 9.0.0-preview36 | 589 | 7/28/2026 |
| 9.0.0-preview35 | 275 | 7/27/2026 |
| 9.0.0-preview34 | 285 | 7/27/2026 |
| 9.0.0-preview33 | 319 | 6/15/2026 |
| 9.0.0-preview32 | 294 | 6/14/2026 |
| 9.0.0-preview31 | 301 | 5/20/2026 |
| 9.0.0-preview30 | 292 | 5/19/2026 |
| 9.0.0-preview29 | 297 | 5/15/2026 |