Configuration & Integrations
EricksonLopez.Result isolates every framework dependency into dedicated satellite packages so Domain projects stay dependency-free.
Register ProblemDetails mapping and endpoint filters with EricksonLopez.Result.AspNetCore:
using System;using EricksonLopez.Result.AspNetCore;using EricksonLopez.Result.OpenApi;using Microsoft.AspNetCore.Builder;using Microsoft.Extensions.DependencyInjection;
namespace Example.Api;
public static class ResultEndpointRegistration{ public static void ConfigureServices(IServiceCollection services) { services.AddResultProblemDetails(); services.AddResultExceptionHandler(); services.AddResultHttpOptions(options => { options.IncludeDescription = false; // Safer production default (RESULT009) options.TypeUriBase = "https://errors.example.com/"; }); }
public static void MapSampleEndpoint(WebApplication app) { app.MapGet("/orders/{id:guid}", static (Guid id) => EricksonLopez.Result.Result.Success(new { OrderId = id })) .AddResultEndpointFilter() .ProducesResult<object>() .ProducesResultProblemDetails(); }}OpenTelemetry, FluentValidation, EF Core & Serialization
Section titled “OpenTelemetry, FluentValidation, EF Core & Serialization”- OpenTelemetry (
EricksonLopez.Result.OpenTelemetry): Callservices.AddResultMetrics()and chain.TraceOutcome(...)viaResultActivityExtensions(ResultMetrics.StaticTrackSuccess/StaticTrackFailure). - FluentValidation (
EricksonLopez.Result.FluentValidation):ValidateToResult(),ValidateToResultWithValue(), andToValidationResult()automatically redact sensitive properties (password,token,secret,creditcard,cardnumber,cvv,ssn,pin,apikey,auth) to"[REDACTED]". - System.Text.Json (
EricksonLopez.Result.Serialization): CalljsonOptions.AddResultConverters()or composeResultJsonSerializerContext;ErrorJsonConverterenforcesMaxAllowedDepth = 32. - Entity Framework Core / Polly / Dapr / gRPC / MassTransit / MediatR: Use
SaveChangesAsyncToResult,AddResultRetry,DaprResultStateExtensions,ResultServerInterceptor,UseResultFilter, andAddResultExceptionBehavior.