Lyo.Result
2.0.0
dotnet add package Lyo.Result --version 2.0.0
NuGet\Install-Package Lyo.Result -Version 2.0.0
<PackageReference Include="Lyo.Result" Version="2.0.0" />
<PackageVersion Include="Lyo.Result" Version="2.0.0" />
<PackageReference Include="Lyo.Result" />
paket add Lyo.Result --version 2.0.0
#r "nuget: Lyo.Result, 2.0.0"
#:package Lyo.Result@2.0.0
#addin nuget:?package=Lyo.Result&version=2.0.0
#tool nuget:?package=Lyo.Result&version=2.0.0
Lyo.Result
Result / Result<T> and related types. Distinct from Lyo.Common.Core Result (different namespace and design). Feature libraries pick Lyo.Result when they want Error graphs, builders, bulk/paged envelopes, and Task composition without pulling the whole API layer.
Result<T> and IResult<T>
Data,IsSuccess,Timestamp,Errors,Metadata(optional key/value bag onResultBase).- Factory methods.
Result<T>.Success(...),Failure(Error),Failure(IReadOnlyList<Error>),Failure(message, code, …),Failure(Exception, …). - Unwrap / extract.
ValueOrThrow,TryGetValue,ValueOrDefault,Match,MapAsync/Map,Tapside effects, boolean operators where defined on the record.
Error
Error is an immutable record with Code, Message, Type, and Severity (ErrorType: Validation, Generic, Conflict, NotFound, Unauthorized, and more). It also has Exception, StackTrace, InnerError (chained errors mimic exception chains), Timestamp, and Metadata. Factory helpers on Error include Validation, FromException, Conflict, NotFound, and Unauthorized, so call sites do not hand-roll severity/type for common cases. Validation-specific codes often flow through ValidationErrorCodes.
Success with no data, and void
ResultVoidcovers operation completed, no payload, alongsideResult<T>(seeResultVoid.cs).Unitis a typed no-value placeholder where APIs wantResult<Unit>.
Option<T>
A missing value is not a failed operation. That is what Option is for, and it is not Result. Typical case: an optional query row.
Builders
- ResultBuilder<T>. Fluent
WithFailure/WithSuccess/AddError/WithMetadata/Build(). - BulkResultBuilder. Accumulate many item-level outcomes into
BulkResult. - ErrorBuilder. Compose
Errorgraphs (metadata, nested inner errors).
Results paired with the request
- Result<TRequest, TResult>. Extends
Result<TResult>with the originalTRequestpayload, so failure paths can echo back the input that produced the error. AddsTryGetRequest, a four-tupleDeconstruct, and request-awareFailure(Exception, …)/Successfactories. - BulkResult<TRequest, TResult>. Bulk variant whose
SuccessfulResults,Results, andFailedResultscollections are paired (Result<TRequest, TResult>), plusFailedRequests/SuccessfulRequestsprojections for re-driving partial failures. - BulkResultFromRequest<TRequest, TResult>. A single request that expands into many per-item results (e.g. one upload to many row outcomes), with
FromResults,FromData,FromException, andFromErrorshelpers.
Paging and lists
- BulkResult<T>. Many operations in one round-trip with cached
FailureCount/SuccessCount,IsCompleteFailure/IsCompleteSuccess/HasPartialSuccessflags,ErrorMessages/ErrorCodes(flattened over inner errors),FailedData/SuccessfulData, andFromData/FromResults/FromErrorsfactories. - PagedResult. Items as a
Resultenvelope plus page metadata.
Composition on async paths
AsyncResultExtensions provides ThenAsync (chain Task<Result<…>> only on success), OnFailureAsync / OnSuccessAsync, overloads that propagate CancellationToken, and adapters from Task plus exceptions into Result. Use these to keep async pipelines linear without nested if (!result.IsSuccess) return ….
Validation and guards
ValidationHelpers and Ensure express preconditions and collect validation failures into Result / Error shapes (see XML docs on each file).
Adapters from exception to Result
Adapters on ExceptionExtensions for code that throws:
| Extension | Purpose |
|---|---|
Exception.ToResult<T>(code?) |
Wraps an exception as Result<T>.Failure(exception, code). |
Task<T>.ToResultAsync<T>(code?) |
Awaits the task; success → Result<T>.Success, exception → Result<T>.Failure. |
Task<Result<T>>.ToResultAsync<T>(code?) |
Awaits a result-returning task and converts thrown exceptions into a failed Result<T>. |
Logging
ResultLoggingExtensions attach log scopes for failure and success that carry the same fields your logging config can correlate.
Infrastructure / regex
RegexPatterns hosts shared validation patterns used by higher layers (route slugs, emails, and similar). Check call sites before assuming a specific regex is the product rule.
How this relates to encryption and HTTP
Lyo.EncryptionshipsDecryptionResult/EncryptionResultmodels in this namespace for operations that wantResultwithout throwing for routine failure modes.- SMS and translation envelope stacks reference
Lyo.ResultforErrortyping in their public models.
Related reading
- Often returns structured failures compatible with richer error handling in hosts:
Lyo.Validation. - Guard helpers shared with keystore and validation stacks:
Lyo.Exceptions.
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Exceptions(direct, lyo)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Lyo.Exceptions (>= 2.0.0)
-
net10.0
- Lyo.Exceptions (>= 2.0.0)
NuGet packages (35)
Showing the top 5 NuGet packages that depend on Lyo.Result:
| Package | Downloads |
|---|---|
|
Lyo.Compression
A production-ready .NET compression library providing efficient, thread-safe compression for the built-in BCL algorithms (GZip, Deflate, and on net10+ Brotli, ZLib). Additional algorithms (LZ4, LZMA, Snappier, Zstd, BZip2, XZ) ship as separate Lyo.Compression.* addon packages so consumers only pay for what they use. |
|
|
Lyo.Encryption
A production-ready .NET encryption library providing secure, authenticated encryption with support for multiple algorithms (AES-GCM, ChaCha20Poly1305, RSA), key management, and envelope encryption patterns. |
|
|
Lyo.Validation
Reusable validators and a fluent builder for validating strongly typed models with structured Result-based failures. |
|
|
Lyo.Web.Components
Blazor components library for the Lyo web UI framework with MudBlazor integration. |
|
|
Lyo.MessageQueue
Message queue service interface and base implementation for asynchronous messaging. |
GitHub repositories
This package is not used by any popular GitHub repositories.