Lyo.Result
1.0.6
dotnet add package Lyo.Result --version 1.0.6
NuGet\Install-Package Lyo.Result -Version 1.0.6
<PackageReference Include="Lyo.Result" Version="1.0.6" />
<PackageVersion Include="Lyo.Result" Version="1.0.6" />
<PackageReference Include="Lyo.Result" />
paket add Lyo.Result --version 1.0.6
#r "nuget: Lyo.Result, 1.0.6"
#:package Lyo.Result@1.0.6
#addin nuget:?package=Lyo.Result&version=1.0.6
#tool nuget:?package=Lyo.Result&version=1.0.6
Lyo.Result
Result / Result<T> and related types. Separate from Lyo.Common 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>
IsSuccess,Data,Errors,Timestamp,Metadata(optional key/value bag onResultBase).- Factory methods.
Result<T>.Success(...),Failure(IReadOnlyList<Error>),Failure(Error),Failure(message, code, …),Failure(Exception, …). - Unwrap / extract.
TryGetValue,ValueOrThrow,ValueOrDefault,Match,Map/MapAsync,Tapside effects, boolean operators where defined on the record.
Error
Error is an immutable record with Message, Code, Severity, and Type (ErrorType: Generic, Validation, NotFound, Conflict, Unauthorized, and more). It also has StackTrace, Exception, InnerError (chained errors mimic exception chains), Metadata, and Timestamp. Factory helpers on Error include FromException, Validation, NotFound, Conflict, and Unauthorized, so call sites do not hand-roll severity/type for common cases. Validation-specific codes often flow through ValidationErrorCodes.
Void and non-data success
ResultVoidcovers operation completed, no payload, alongsideResult<T>(seeResultVoid.cs).Unitis a typed no-value placeholder where APIs wantResult<Unit>.
Option<T>
Optional presence without treating no value as a failed operation. Distinct from Result. Use Option when absence is not an error (e.g. optional query row).
Builders
- ResultBuilder<T>. Fluent
WithSuccess/WithFailure/AddError/WithMetadata/Build(). - BulkResultBuilder. Accumulate many item-level outcomes into
BulkResult. - ErrorBuilder. Compose
Errorgraphs (nested inner errors, metadata).
Request-paired results
- 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-awareSuccess/Failure(Exception, …)factories. - BulkResult<TRequest, TResult>. Bulk variant whose
Results,SuccessfulResults, andFailedResultscollections are paired (Result<TRequest, TResult>), plusSuccessfulRequests/FailedRequestsprojections 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
FromData,FromResults,FromErrors, andFromExceptionhelpers.
Lists and paging
- BulkResult<T>. Many operations in one round-trip with cached
SuccessCount/FailureCount,IsCompleteSuccess/IsCompleteFailure/HasPartialSuccessflags,ErrorCodes/ErrorMessages(flattened over inner errors),SuccessfulData/FailedData, andFromResults/FromData/FromErrorsfactories. - PagedResult. Page metadata plus items as a
Resultenvelope.
Async composition
AsyncResultExtensions provides ThenAsync (chain Task<Result<…>> only on success), OnSuccessAsync / OnFailureAsync, 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 ….
Guards and validation
Ensure and ValidationHelpers express preconditions and collect validation failures into Error / Result shapes (see XML docs on each file).
Exception to Result adapters
ExceptionExtensions adapters for exception-throwing code:
| 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 success and failure that carry the same fields your logging config can correlate.
Regex / infrastructure
RegexPatterns hosts shared validation patterns used by higher layers (emails, route slugs, and similar). Check call sites before assuming a specific regex is the product rule.
Relationship to encryption and HTTP
Lyo.EncryptionshipsEncryptionResult/DecryptionResultmodels in this namespace for operations that wantResultwithout throwing for routine failure modes.- Translation and SMS envelope stacks reference
Lyo.ResultforErrortyping in their public models.
When to choose this vs Lyo.Common.Result
- Prefer
Lyo.Resultwhen you need multiple errors, severity/type, bulk/paged wrappers, or asyncThenAsyncchains. - Prefer
Lyo.Commonprimitives when you are only inside code that already standardized on thatResulttype and you do not want two result types in the same boundary.
See also
Lyo.Validation. Often returns structured failures compatible with richer error handling in hosts.Lyo.Exceptions. Guard helpers shared with validation and keystore stacks.
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Common(direct, lyo)Lyo.Exceptions(direct, lyo)System.Text.Json10.0.5(direct, microsoft, netstandard2.0)Microsoft.Extensions.Logging.Abstractions10.0.5(transitive, microsoft)System.Memory4.6.3(transitive, microsoft, netstandard2.0)
| 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.Common (>= 1.0.6)
- Lyo.Exceptions (>= 1.0.6)
- System.Text.Json (>= 10.0.5)
-
net10.0
- Lyo.Common (>= 1.0.6)
- Lyo.Exceptions (>= 1.0.6)
NuGet packages (32)
Showing the top 5 NuGet packages that depend on Lyo.Result:
| Package | Downloads |
|---|---|
|
Lyo.Query.Models
Query models for building and representing queries - QueryNode, QueryRequest, ConditionNode, SortBy, builders. Shared by Lyo.Query and Lyo.Api. |
|
|
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.Web.Components
Blazor components library for the Lyo web UI framework with MudBlazor integration. |
|
|
Lyo.Validation
Reusable validators and a fluent builder for validating strongly typed models with structured Result-based failures. |
GitHub repositories
This package is not used by any popular GitHub repositories.