EricksonLopez.SharedKernel 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package EricksonLopez.SharedKernel --version 2.0.0
                    
NuGet\Install-Package EricksonLopez.SharedKernel -Version 2.0.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="EricksonLopez.SharedKernel" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EricksonLopez.SharedKernel" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="EricksonLopez.SharedKernel" />
                    
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 EricksonLopez.SharedKernel --version 2.0.0
                    
#r "nuget: EricksonLopez.SharedKernel, 2.0.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 EricksonLopez.SharedKernel@2.0.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=EricksonLopez.SharedKernel&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=EricksonLopez.SharedKernel&version=2.0.0
                    
Install as a Cake Tool

EricksonLopez.SharedKernel

NuGet NuGet Downloads CI Coverage Mutation Score License: MIT .NET NativeAOT

A minimal, high-performance Shared Kernel for DDD-based .NET applications. Provides zero-dependency, AOT-compatible domain primitives: Entity<TId>, AggregateRoot<TId>, and IDomainEvent. Designed for Clean Architecture and CQRS.

⚡ Performance

BenchmarkDotNet v0.14.0 · .NET 10.0 · X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI

Focus: Extreme low allocation for domain event sourcing.

Event Sourcing — Lazy Allocation

Method Mean Allocated Alloc Ratio
RaiseEvent_FirstTime 12.4 ns 64 B 1.0×
RaiseEvent_Subsequent 5.2 ns 0 B 0.0×
ClearEvents 1.1 ns 0 B 0.0×

Key takeaways:

  • Zero-allocation domain events collection until the first event is raised.
  • Minimal 64 B allocation strictly for the backing list on the first event.
  • O(1) clearing of events with absolutely zero allocations.

Performance Guide

Key Features

  • Zero Dependencies: Keep your core domain pure. No third-party dependencies.
  • AOT Ready: IsAotCompatible=true and IsTrimmable=true are active on all supported TFMs, providing real Native AOT compatibility analysis at compile time.
  • Lazy Allocation: Domain event collections allocate memory strictly when the first event is raised, optimizing memory footprint.
  • Identity Equality: Pre-optimized GetHashCode() and equality operators (==, !=) out of the box for Domain Entities.

What's Included

Type Description
Entity<TId> Abstract base for domain entities with identity-based equality (type + Id). Includes IsTransient(), ==/!= operators, and an optimized GetHashCode().
AggregateRoot<TId> Transactional consistency boundary. Inherits Entity<TId> and adds domain event support with lazy allocation.
IDomainEvent Marker interface for domain events.

This library intentionally does not include infrastructure abstractions (UnitOfWork, Repositories) or additional patterns (Result, ValueObject, Specification). The goal is to keep the domain core completely pure and dependency-free.

.NET Framework Support Policy

All library packages target net8.0, net9.0, and net10.0.

Support Policy: This library supports only .NET frameworks with active official support from Microsoft. A framework version is included in TargetFrameworks as long as it appears on the Microsoft .NET Support Policy page under Active or Maintenance status. Framework versions are removed from TargetFrameworks when they reach their official end-of-life date as defined by Microsoft — not before, and not after.

Framework Type Microsoft Support End Date Status
.NET 8 LTS November 10, 2026 ✅ Supported
.NET 9 STS November 10, 2026 ✅ Supported
.NET 10 LTS November 2028 ✅ Supported

Quick Start

  1. Install the package:

    dotnet add package EricksonLopez.SharedKernel
    
  2. Start using the domain primitives:

    using EricksonLopez.SharedKernel;
    
    // 1. Define a domain event
    public sealed record OrderPlacedEvent(Guid OrderId) : IDomainEvent;
    
    // 2. Define an Aggregate Root
    public sealed class Order : AggregateRoot<Guid>
    {
        private Order() { }
    
        public static Order Place(Guid id)
        {
            var order = new Order { Id = id };
            order.RaiseDomainEvent(new OrderPlacedEvent(id));
            return order;
        }
    }
    
    // 3. Use it
    var order = Order.Place(Guid.NewGuid());
    Console.WriteLine(order.DomainEvents.Count); // 1
    order.ClearDomainEvents();
    

Showcase

The repository includes a runnable reference project at samples/EricksonLopez.SharedKernel.Sample/. It demonstrates all public API members across multiple use-case levels.

dotnet run --project samples/EricksonLopez.SharedKernel.Sample/EricksonLopez.SharedKernel.Sample.csproj

Documentation

Topic Link
Quick Start docs/QUICK_START.md
Getting Started docs/GETTING_STARTED.md
API Reference docs/API_REFERENCE.md
Cookbook docs/Cookbook.md
Best Practices docs/BestPractices.md
Anti-Patterns docs/AntiPatterns.md
Architecture Guide docs/Architecture.md
Performance Guide docs/PERFORMANCE_GUIDE.md
Migration Guide docs/MigrationGuide.md
CI/CD Pipeline docs/ci-cd.md
FAQ docs/FAQ.md
Troubleshooting docs/TROUBLESHOOTING.md
Design Decisions (ADRs) docs/decisions/

Contributing

See CONTRIBUTING.md for information on building the project, running tests, and contributing guidelines.

Security

Please review SECURITY.md for details on our security policies and how to report vulnerabilities.

Code of Conduct

We follow the Contributor Covenant. See CODE_OF_CONDUCT.md for details.

License

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

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 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 is compatible.  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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on EricksonLopez.SharedKernel:

Package Downloads
EricksonLopez.DapperExtensions.PostgreSQL

High-performance Dapper extensions for PostgreSQL. Bulk insert and upsert via UNNEST (10-50x faster than row-by-row), paginated queries returning PagedList<T>, transaction helpers, and JSONB type handler. Designed for enterprise .NET applications using Clean Architecture.

EricksonLopez.SharedKernel.Testing

Testing SDK for EricksonLopez.SharedKernel. Provides domain event collectors, assertions, and test helpers for aggregate roots.

EricksonLopez.SharedKernel.OpenTelemetry

OpenTelemetry tracing and metrics instrumentation for EricksonLopez.SharedKernel domain events. NativeAOT and Trimming compatible.

EricksonLopez.SharedKernel.Dapper

Dapper TypeHandler adapters and registration extensions for EricksonLopez.SharedKernel strong identifiers.

EricksonLopez.SharedKernel.EntityFrameworkCore

Entity Framework Core integration for EricksonLopez.SharedKernel. Provides NativeAOT-ready StrongId value converters, DomainEventsInterceptor for automatic event draining on SaveChanges, and ModelBuilder conventions.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 186 8/25/2026
2.0.0 111 8/12/2026
1.1.0 131 7/23/2026
1.0.1 113 7/21/2026
1.0.0 256 7/16/2026