CaseNet 1.3.0-preview.0.1

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

CaseNet

A .NET library that simplifies the Use Case pattern through source generation, automatically creating interfaces and interactors for your use cases.

Features

  • Clean use case abstraction with IUseCase<TRequest, TResponse>
  • Source generator that automatically creates interfaces and interactor classes
  • Dynamic service collection registration via extension methods
  • Behavior pipeline support via IUseCaseBehavior for cross-cutting concerns
  • Seamless integration with ASP.NET Core and dependency injection

Usage

Define a Use Case

Implement the IUseCase<TRequest, TResponse> interface:

public class CreateUser : IUseCase<CreateUserRequest, CreateUserResponse>
{
    public Task<CreateUserResponse> ExecuteAsync(CreateUserRequest request, CancellationToken cancellationToken)
    {
        // Implementation
    }
}

The source generator automatically creates:

  • An ICreateUser interface
  • A CreateUserInteractor class that implements the interface. This class wraps CreateUser with the behavior pipeline

Register Use Cases

Add use cases to the service collection by calling services.Add{ProjectName}UseCases(), where ProjectName is your project's assembly name:

services.AddMyProjectUseCases();

Execute use case

Inject the generated interface where you need to call use case:

public class UserService
{
    public async Task CreateUserAsync(
        CreateUserRequest request,
        ICreateUser useCase,
        CancellationToken cancellationToken)
    {
        var response = await useCase.ExecuteAsync(request, cancellationToken);
    }
}

Add Behaviors

Behaviors implement the pipeline pattern for cross-cutting concerns like logging, validation, or error handling:

public class LoggingBehavior<TRequest, TResponse>
    : IUseCaseBehavior<TRequest, TResponse>
{
    private readonly ILogger<LoggingBehavior<TRequest, TResponse>> _logger;

    public LoggingBehavior(ILogger<LoggingBehavior<TRequest, TResponse>> logger)
    {
        _logger = logger;
    }

    public async Task<TResponse> HandleAsync(
        TRequest request,
        InteractorContext<TRequest, TResponse> context,
        CancellationToken ct)
    {
        _logger.LogInformation("Handling {Request}", typeof(TRequest).Name);

        var response = await context.NextAsync(request, ct);

        _logger.LogInformation("Handled {Request}", typeof(TRequest).Name);

        return response;
    }
}

Register behaviors as open generics in the service collection. This allows the interactor to discover and apply them:

services.AddScoped(typeof(IUseCaseBehavior<,>), typeof(LoggingBehavior<,>));
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 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 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.
  • .NETStandard 2.1

    • No dependencies.

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
1.3.0-preview.0.1 46 5/4/2026
1.2.0 87 4/28/2026
1.1.0 62 4/28/2026