CaseNet 1.3.0-preview.0.1
dotnet add package CaseNet --version 1.3.0-preview.0.1
NuGet\Install-Package CaseNet -Version 1.3.0-preview.0.1
<PackageReference Include="CaseNet" Version="1.3.0-preview.0.1" />
<PackageVersion Include="CaseNet" Version="1.3.0-preview.0.1" />
<PackageReference Include="CaseNet" />
paket add CaseNet --version 1.3.0-preview.0.1
#r "nuget: CaseNet, 1.3.0-preview.0.1"
#:package CaseNet@1.3.0-preview.0.1
#addin nuget:?package=CaseNet&version=1.3.0-preview.0.1&prerelease
#tool nuget:?package=CaseNet&version=1.3.0-preview.0.1&prerelease
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
IUseCaseBehaviorfor 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
ICreateUserinterface - A
CreateUserInteractorclass that implements the interface. This class wrapsCreateUserwith 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 | Versions 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. |
-
.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 |