UsecatR 0.0.2

dotnet add package UsecatR --version 0.0.2
                    
NuGet\Install-Package UsecatR -Version 0.0.2
                    
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="UsecatR" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UsecatR" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="UsecatR" />
                    
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 UsecatR --version 0.0.2
                    
#r "nuget: UsecatR, 0.0.2"
                    
#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 UsecatR@0.0.2
                    
#: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=UsecatR&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=UsecatR&version=0.0.2
                    
Install as a Cake Tool

UsecatR

CI Coverage NuGet NuGet Downloads License

UsecatR is a lightweight Use Case (Interactor) execution pipeline for .NET, designed to fit naturally into Clean Architecture applications.

It provides a simple and explicit way to execute Use Cases, with support for pipeline behaviors such as logging, validation, transactions, caching, and more — without heavy frameworks or magic conventions.

Think of UsecatR as a clean, minimal alternative to MediatR, focused exclusively on the Application Layer.


Installation

UsecatR is distributed as a single NuGet package.

dotnet add package UsecatR

Core Concepts

Concept Description
IUseCaseRequest<TResult> Input model of a Use Case
IUseCaseHandler<TRequest, TResult> Executes the Use Case
IUseCaseBehavior<TRequest, TResult> Cross-cutting pipeline behavior
IUsecatR Entry point used to execute Use Cases

Basic Usage

1. Define a Use Case request

using UsecatR.Abstractions;

public sealed record CreateCustomer(
    string Name,
    string Email
) : IUseCaseRequest<Guid>;

2. Implement the Use Case handler

using UsecatR.Abstractions;

public sealed class CreateCustomerHandler
    : IUseCaseHandler<CreateCustomer, Guid>
{
    public Task<Guid> HandleAsync(CreateCustomer request, CancellationToken ct)
    {
        // Application logic goes here
        return Task.FromResult(Guid.NewGuid());
    }
}

3. Register UsecatR and handlers

using UsecatR.DependencyInjection;

builder.Services.AddUsecatR(
    typeof(CreateCustomerHandler).Assembly
);

4. Execute the Use Case

using UsecatR.Abstractions;

public sealed class CustomersController : ControllerBase
{
    private readonly IUsecatR _UsecatR;

    public CustomersController(IUsecatR UsecatR)
    {
        _UsecatR = UsecatR;
    }

    [HttpPost]
    public async Task<IActionResult> Create(CreateCustomer input, CancellationToken ct)
    {
        var id = await _UsecatR.ExecuteAsync<CreateCustomer, Guid>(input, ct);
        return Ok(id);
    }
}

Pipeline Behaviors

Pipeline behaviors allow you to add cross-cutting concerns around Use Case execution.

Behavior contract

public interface IUseCaseBehavior<in TRequest, TResult>
    where TRequest : IUseCaseRequest<TResult>
{
    Task<TResult> HandleAsync(
        TRequest request,
        UseCaseHandlerDelegate<TResult> next,
        CancellationToken ct);
}

Example: Logging behavior

using UsecatR.Abstractions;

public sealed class LoggingBehavior<TRequest, TResult>
    : IUseCaseBehavior<TRequest, TResult>
    where TRequest : IUseCaseRequest<TResult>
{
    public async Task<TResult> HandleAsync(
        TRequest request,
        UseCaseHandlerDelegate<TResult> next,
        CancellationToken ct)
    {
        Console.WriteLine($"Starting {typeof(TRequest).Name}");
        var result = await next();
        Console.WriteLine($"Finished {typeof(TRequest).Name}");
        return result;
    }
}

Clean Architecture Alignment

UsecatR is designed to live in the Application Layer.


License

MIT

Product 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 is compatible.  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 was computed.  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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.2 441 12/23/2025
0.0.1 287 12/23/2025