Lyo.Result
1.0.2
dotnet add package Lyo.Result --version 1.0.2
NuGet\Install-Package Lyo.Result -Version 1.0.2
<PackageReference Include="Lyo.Result" Version="1.0.2" />
<PackageVersion Include="Lyo.Result" Version="1.0.2" />
<PackageReference Include="Lyo.Result" />
paket add Lyo.Result --version 1.0.2
#r "nuget: Lyo.Result, 1.0.2"
#:package Lyo.Result@1.0.2
#addin nuget:?package=Lyo.Result&version=1.0.2
#tool nuget:?package=Lyo.Result&version=1.0.2
Lyo.Result
Railway-oriented Result / Result<T> and related types. This package is orthogonal to Lyo.Common Result (different namespace and design); many feature libraries pick Lyo.Result when they want rich Error graphs, builders, bulk/paged envelopes, and Task composition without pulling the whole API layer.
Concepts — 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, Tap side effects, boolean operators where defined on the record.
Concepts — Error
Error is an immutable record with: - Message, Code, Severity, Type (ErrorType: Generic, Validation, NotFound, Conflict, Unauthorized, …). - StackTrace, Exception, InnerError (chained errors mimic exception chains). - Metadata, Timestamp. Factory helpers on Error include FromException, Validation, NotFound, Conflict, Unauthorized, etc., so call sites do not hand-roll severity/type for common cases. Validation-specific codes often flow through ValidationErrorCodes.
Concepts — Void and non-data success
ResultVoid/ patterns for “operation completed, no payload” live alongsideResult<T>(seeResultVoid.csusage in your solution).Unitrepresents a typed “no value” placeholder where APIs wantResult<Unit>.
Concepts — Option<T>
Optional presence without conflating “failed operation” with “no value”. Distinct from Result: use Option when absence is not an error (e.g. optional query row).
Concepts — Builders
ResultBuilder<T>— fluentWithSuccess/WithFailure/AddError/WithMetadata/Build().BulkResultBuilder— accumulate many item-level outcomes intoBulkResult.ErrorBuilder— compose complexErrorgraphs (nested inner errors, metadata).
Concepts — Request-paired results
Result<TRequest, TResult>— extendsResult<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 whoseResults,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 → many row outcomes), withFromData,FromResults,FromErrors, andFromExceptionhelpers.
Concepts — Lists and paging
BulkResult<T>— many operations in one round-trip with cachedSuccessCount/FailureCount,IsCompleteSuccess/IsCompleteFailure/HasPartialSuccessflags,ErrorCodes/ErrorMessages(flattened over inner errors),SuccessfulData/FailedData, andFromResults/FromData/FromErrorsfactories.PagedResult— page metadata + items as aResultenvelope.
Concepts — Async composition
AsyncResultExtensions provides ThenAsync (chain Task<Result<…>> only on success), OnSuccessAsync / OnFailureAsync, overloads that propagate * *CancellationToken**, and adapters from Task + exceptions into Result. Use these to keep async pipelines linear without nested if (!result.IsSuccess) return … noise.
Concepts — Guards and validation
Ensure and ValidationHelpers express preconditions and collect validation failures into Error / Result shapes (see XML docs on each file).
Concepts — Exception → Result adapters
ExceptionExtensions provides drop-in 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>. |
Concepts — Logging
ResultLoggingExtensions attach consistent log scopes for success/failure (OpenTelemetry/correlation-friendly when paired with your logging config).
Concepts — Regex / infrastructure
RegexPatterns hosts shared validation patterns used by higher layers (emails, route slugs, etc.—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 thatResultsurface 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.2)
- Lyo.Exceptions (>= 1.0.2)
- System.Text.Json (>= 10.0.5)
-
net10.0
- Lyo.Common (>= 1.0.2)
- Lyo.Exceptions (>= 1.0.2)
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.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.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.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. |
GitHub repositories
This package is not used by any popular GitHub repositories.