DcsvIo.D2.Handler.Abstractions 0.1.1

dotnet add package DcsvIo.D2.Handler.Abstractions --version 0.1.1
                    
NuGet\Install-Package DcsvIo.D2.Handler.Abstractions -Version 0.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DcsvIo.D2.Handler.Abstractions" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DcsvIo.D2.Handler.Abstractions" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="DcsvIo.D2.Handler.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DcsvIo.D2.Handler.Abstractions --version 0.1.1
                    
#r "nuget: DcsvIo.D2.Handler.Abstractions, 0.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DcsvIo.D2.Handler.Abstractions@0.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DcsvIo.D2.Handler.Abstractions&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=DcsvIo.D2.Handler.Abstractions&version=0.1.1
                    
Install as a Cake Tool

DcsvIo.D2.Handler.Abstractions

Domain-safe slice of the handler stack: IHandler<in TInput, TOutput>, IHandlerContext, HandlerOptions. Domain code references this; the runtime piece (BaseHandler, HandlerContext, HandlerTelemetry, AddD2Handler) lives in DcsvIo.D2.Handler.

Install

dotnet add package DcsvIo.D2.Handler.Abstractions

Public surface

public interface IHandler<in TInput, TOutput>
{
    ValueTask<D2Result<TOutput?>> HandleAsync(
        TInput input,
        CancellationToken ct = default,
        HandlerOptions? options = null);
}

public interface IHandlerContext
{
    IRequestContext Request { get; }
    ILogger Logger { get; }
}

public sealed record HandlerOptions
{
    public bool LogInput { get; init; } = true;
    public bool LogOutput { get; init; } = true;
    public TimeSpan? SlowThreshold { get; init; } = TimeSpan.FromMilliseconds(100);
    public TimeSpan? CriticalThreshold { get; init; } = TimeSpan.FromMilliseconds(500);
    public ScopeRequirement? ScopeRequirement { get; init; }
}

/// <summary>Declares the per-handler scope requirement.</summary>
public sealed record ScopeRequirement(HandlerScopeMatch Match, IReadOnlySet<string> Scopes);

public enum HandlerScopeMatch { Any, All }

ScopeRequirement combines an explicit match mode with the scope set: Match is HandlerScopeMatch.Any (caller must hold at least one of the scopes) or HandlerScopeMatch.All (caller must hold every scope). null or an empty Scopes set disables the per-handler pre-check entirely (pipeline guard is { Scopes.Count: > 0 } skips). HandlerScopeMatch lives in this assembly — handlers never take a compile-time dependency on DcsvIo.D2.Auth.Abstractions (layer-hygiene invariant).

JWT signature / expiry / audience / fingerprint-binding validation are NOT per-handler. They're transport-level concerns handled by auth middleware (HTTP / gRPC / AMQP) BEFORE the handler runs. Per-handler scope requirements (ScopeRequirement) ARE here because they vary by operation; audience / signature / etc. are per-service constants and putting them on HandlerOptions would be a footgun. See HandlerOptions remarks for the fuller rationale.


Why split from DcsvIo.D2.Handler?

Domain code (entities + value objects + domain services) shouldn't depend on Microsoft.Extensions.DependencyInjection, OpenTelemetry, or any infrastructure package. The split lets domain projects reference only this lib (and pick up IHandler for handler-shaped domain services); the concrete + DI extension live in the sibling package DcsvIo.D2.Handler.


Dependencies

  • DcsvIo.D2.ResultD2Result<T> return type
  • DcsvIo.D2.Context.AbstractionsIRequestContext on the context
  • Microsoft.Extensions.Logging.AbstractionsILogger on the context

  • DcsvIo.D2.Handler — concrete BaseHandler + HandlerContext + DI extension
  • DcsvIo.D2.Handler.Repo — EF-flavored handler that maps PG/EF exceptions to D2Result failure codes

Recommended layout: per-op handler folders (Application/Handlers/{Commands,Queries}/<Op>/).

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on DcsvIo.D2.Handler.Abstractions:

Package Downloads
DcsvIo.D2.Handler

BaseHandler for D2 — the abstract base every handler inherits, providing scope pre-checks, OpenTelemetry activity and metrics, log scope, and a universal try/catch.

DcsvIo.D2.Handler.Repo

EF-flavored BaseRepoHandler for D2 — converts database exceptions captured during execution into typed D2Result failures.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1 146 7/17/2026
0.1.0 153 7/17/2026