Sinter 1.1.0

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

CI/CD Pipeline

Sinter

A lightweight, easy-to-use mediator pattern implementation for .NET applications. Perfect for implementing CQRS patterns without the complexity.

🚀 Features

  • Blazing Fast - Uses compiled expression trees instead of reflection
  • Zero Allocations - After initial warm-up, no heap allocations
  • Simple API - Just one method to remember: Send
  • Thread-Safe - Concurrent handler resolution with cached compilations
  • Dependency Injection - Full support for constructor injection in handlers
  • Minimal Dependencies - Only requires Microsoft.Extensions.DependencyInjection.Abstractions

📦 Installation

dotnet add package Sinter

Or via Package Manager:

Install-Package Sinter

🔧 Quick Start

1. Define a Query/Command

// Query with response
public class GetUserByIdQuery : IRequest<UserDto>
{
    public int Id { get; set; }
}

// Command without response
public class DeleteUserCommand : IRequest
{
    public int Id { get; set; }
}

2. Create Handlers

public class GetUserByIdQueryHandler : IRequestHandler<GetUserByIdQuery, UserDto>
{
    private readonly IUserRepository _repository;
    
    public GetUserByIdQueryHandler(IUserRepository repository)
    {
        _repository = repository;
    }
    
    public async Task<UserDto> Handle(GetUserByIdQuery request, CancellationToken cancellationToken)
    {
        var user = await _repository.GetByIdAsync(request.Id);
        return new UserDto { Id = user.Id, Name = user.Name };
    }
}

public class DeleteUserCommandHandler : IRequestHandler<DeleteUserCommand>
{
    private readonly IUserRepository _repository;
    
    public DeleteUserCommandHandler(IUserRepository repository)
    {
        _repository = repository;
    }
    
    public async Task<Unit> Handle(DeleteUserCommand request, CancellationToken cancellationToken)
    {
        await _repository.DeleteAsync(request.Id);
        return Unit.Value;
    }
}

3. Register Services

// In Program.cs or Startup.cs
builder.Services.AddSinter(typeof(GetUserByIdQuery).Assembly);

4. Use in Controllers

[ApiController]
[Route("api/[controller]")]
public class UsersController : ControllerBase
{
    private readonly IDispatcher _dispatcher;
    
    public UsersController(IDispatcher dispatcher)
    {
        _dispatcher = dispatcher;
    }
    
    [HttpGet("{id}")]
    public async Task<ActionResult<UserDto>> Get(int id)
    {
        var result = await _dispatcher.Send(new GetUserByIdQuery { Id = id });
        return Ok(result);
    }
    
    [HttpDelete("{id}")]
    public async Task<IActionResult> Delete(int id)
    {
        await _dispatcher.Send(new DeleteUserCommand { Id = id });
        return NoContent();
    }
}

🎯 API Reference

IDispatcher

public interface IDispatcher
{
    Task<TResponse> Send<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken = default);
    Task Send(IRequest request, CancellationToken cancellationToken = default);
}

Request Interfaces

// Request with response
public interface IRequest<out TResponse> { }

// Request without response (returns Unit)
public interface IRequest : IRequest<Unit> { }

Handler Interfaces

// Handler with response
public interface IRequestHandler<in TRequest, TResponse> 
    where TRequest : IRequest<TResponse>
{
    Task<TResponse> Handle(TRequest request, CancellationToken cancellationToken);
}

// Handler without response
public interface IRequestHandler<in TRequest> : IRequestHandler<TRequest, Unit> 
    where TRequest : IRequest<Unit> { }

🏗️ Advanced Usage

Assembly Scanning

services.AddSinter(
    typeof(ApplicationLayer).Assembly,
    typeof(AnotherAssembly).Assembly
);

Lifetime Configuration

All handlers are registered as Scoped by default, matching the dispatcher's lifetime.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

Inspired by MediatR but built for maximum performance with minimal overhead.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
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
1.1.0 79,309 7/21/2025
1.0.0 78,894 7/18/2025