Skip to content

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.

Guides & Production Recipes

L0StableNuGet: v3.0.0Local HEAD: v3.2.0AOT: Partial

Practical production patterns using EricksonLopez.Result (3.0.0) with zero closure allocations and compile-time error generation.

Pass local state explicitly as a TState tuple so lambdas stay static and avoid display-class allocations (RESULT004):

using EricksonLopez.Result;
namespace Example.ResultRecipes;
public static class DiscountPipeline
{
public static Result<decimal> ApplyDiscount(in Result<decimal> subtotalResult, decimal discountRate, decimal minOrder)
{
var state = (discountRate, minOrder);
return subtotalResult
.Ensure(
state,
static (s, amount) => amount >= s.minOrder,
Error.Domain("Discount.MinimumNotMet", "Order subtotal is below discount threshold."))
.Map(
state,
static (s, amount) => amount * (1m - s.discountRate));
}
}

Added in v3.0.0, Result.ValidateAllParallelAsync evaluates independent asynchronous validation checks concurrently and aggregates all failures into a combined Error (WellKnownErrors.CombinedFailuresCode).

Add EricksonLopez.Result.DomainErrors.Generators and include *.errors.json / *.domainerrors.json as <AdditionalFiles> in your .csproj to emit strongly-typed static Error factories at build time (RESULT_DOM_001–003).

using System;
using EricksonLopez.Result;
using EricksonLopez.Result.Maybe;
namespace Example.ResultRecipes;
public static class CustomerLookup
{
public static Result<string> ResolveDisplayName(string? candidate, Guid customerId) =>
Maybe<string>.From(candidate)
.ToResult(Error.NotFound("Customer.NotFound", $"Customer '{customerId}' was not found."));
}