LinKit.Core 1.1.0

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

LinKit.Core

NuGet Version NuGet Downloads

LinKit.Core is a high-performance, modular toolkit for .NET, providing source-generated helpers for CQRS, Dependency Injection, Minimal API Endpoints, Mapping, Messaging, and gRPC. LinKit eliminates boilerplate, maximizes runtime performance, and is fully compatible with NativeAOT and trimming.


Why LinKit?

Most .NET libraries rely on runtime reflection, which is slow, memory-intensive, and incompatible with NativeAOT. LinKit uses C# Source Generators to analyze your code and generate optimized, boilerplate-free C# at compile time, linking your application's components together.

Key Benefits:

  • 🚀 Zero Reflection: No runtime scanning or reflection.
  • Fast Startup: No assembly scanning.
  • 🗑️ AOT & Trimming Safe: Works with Blazor, MAUI, NativeAOT.
  • ✍️ Clean API: Intent-driven, explicit, and easy to use.
  • 🤖 Automated Boilerplate: For DI, API endpoints, gRPC, messaging, and mapping.

LinKit Ecosystem

Package Description NuGet
LinKit.Core Required. Interfaces, attributes, and source generator. NuGet
LinKit.Grpc gRPC server/client codegen for CQRS requests. NuGet
LinKit.Messaging.RabbitMQ RabbitMQ implementation for Messaging Kit. NuGet
LinKit.Messaging.Kafka Kafka implementation for Messaging Kit. NuGet

Installation

dotnet add package LinKit.Core

Add other packages as needed:

dotnet add package LinKit.Grpc
dotnet add package LinKit.Messaging.RabbitMQ

Kits Overview

1. CQRS Kit

A source-generated Mediator for the CQRS pattern.

  • Define Requests: Implement ICommand, ICommand<TResult>, or IQuery<TResult>.
  • Create Handlers: Implement the handler and mark with [CqrsHandler].
  • Register: builder.Services.AddLinKitCqrs();
public class GetUserQuery : IQuery<UserDto>
{
    public int Id { get; set; }
}

[CqrsHandler]
public class GetUserHandler : IQueryHandler<GetUserQuery, UserDto>
{
    public Task<UserDto> Handle(GetUserQuery query, CancellationToken cancellationToken) { ... }
}

Usage:

builder.Services.AddLinKitCqrs();
var user = await mediator.QueryAsync(new GetUserQuery { Id = 1 });

2. Dependency Injection Kit

Attribute-based, source-generated DI registration.

  • Mark Services: [RegisterService(Lifetime.Scoped)] on your class.
  • Register: builder.Services.AddLinKitDependency();
[RegisterService(Lifetime.Scoped)]
public class MyService : IMyService { ... }

Usage:

builder.Services.AddLinKitDependency();

3. Endpoints Kit (Minimal APIs)

Source-generates Minimal API endpoints from CQRS requests.

  • Decorate Requests: [ApiEndpoint] on your command/query.
  • Property Binding: Use [FromRoute], [FromQuery], etc.
  • Register: app.MapGeneratedEndpoints();
[ApiEndpoint(ApiMethod.GET, "users/{Id}")]
public class GetUserQuery : IQuery<UserDto>
{
    [FromRoute] public int Id { get; set; }
}

Usage:

app.MapGeneratedEndpoints();

4. Mapping Kit

A reflection-free, source-generated object mapper.

  • Create Mapper Context: [MapperContext] partial class implementing IMappingConfigurator.
  • Configure Mappings: Use builder.CreateMap<TSrc, TDest>() and .ForMember(...).
  • No DI Required: Just use the generated extension methods.
[MapperContext]
public partial class AppMapperContext : IMappingConfigurator
{
    public void Configure(IMappingBuilder builder)
    {
        builder.CreateMap<User, UserDto>()
            .ForMember(dest => dest.Name, src => src.UserName);
    }
}

Usage:

var dto = userEntity.ToUserDto();
var dtos = userEntities.ToUserDtoList();

Mapping Conventions:

  1. Explicit .ForMember() config
  2. Name matching (case-insensitive)
  3. [JsonPropertyName]/[JsonProperty] attribute matching

5. Messaging Kit

Source-generated publisher/consumer for message brokers (RabbitMQ, Kafka).

  • Mark Messages: [Message] on your event/command.
  • Write Handlers: [CqrsHandler] for the message.
  • Register: builder.Services.AddLinKitMessaging(); and the broker package.
[Message("user-events", RoutingKey = "user.created", QueueName = "email-service-queue")]
public record UserCreatedEvent(int UserId, string Email);

[CqrsHandler]
public class UserCreatedHandler : ICommandHandler<UserCreatedEvent> { ... }

Publisher:

builder.Services.AddLinKitMessaging();
builder.Services.AddLinKitRabbitMQ(configuration);
// await publisher.PublishAsync(new UserCreatedEvent(...));

Consumer:

builder.Services.AddLinKitCqrs();
builder.Services.AddLinKitMessaging();
builder.Services.AddLinKitRabbitMQ(configuration);

6. gRPC Kit (via LinKit.Grpc)

Source-generates gRPC server and client code for CQRS requests.

Server:

  • [GrpcEndpoint(typeof(MyServiceBase), "MethodName")] on CQRS request.
  • Handler: [CqrsHandler]
  • Register: builder.Services.AddLinKitGrpcServer(); and app.MapGrpcService<LinKitMyService>();
[GrpcEndpoint(typeof(UserService.UserServiceBase), "GetUserById")]
public class GetUserQuery : IQuery<UserDto> { ... }

Client:

  • [GrpcClient(typeof(MyServiceClient), "MethodNameAsync")] on CQRS request.
  • Register: builder.Services.AddLinKitGrpcClient(); and IGrpcChannelProvider.
[GrpcClient(typeof(UserService.UserClient), "GetUserByIdAsync")]
public class GetUserQuery : IQuery<UserDto> { ... }

Usage:

var user = await mediator.QueryAsync(new GetUserQuery { Id = 1 });

AOT & Trimming

LinKit is fully compatible with NativeAOT and trimming. For best results, use System.Text.Json source generation for DTOs and messages.


Advanced Configuration

  • All AddLinKit...() methods are additive and can be combined.
  • No manual registration of handlers or mappings is needed.
  • For custom mapping, use the Mapping Kit.
  • For custom gRPC channel, implement IGrpcChannelProvider.

Contributing

Contributions, issues, and feature requests are welcome!


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

NuGet packages (3)

Showing the top 3 NuGet packages that depend on LinKit.Core:

Package Downloads
LinKit.Grpc

gRPC server/client code generation for CQRS requests in LinKit. High-performance, source-generated, AOT/Trimming safe.

LinKit.Messaging.Kafka

Apache Kafka implementation for LinKit.Messaging abstractions.

LinKit.Messaging.RabbitMQ

RabbitMQ implementation for LinKit.Messaging abstractions.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 175 9/12/2025
1.0.9 141 9/10/2025
1.0.8 132 9/5/2025
1.0.7 196 8/29/2025
1.0.5 233 8/26/2025
1.0.3 143 8/21/2025