EricksonLopez.SharedKernel

dotnet-shared-kernel · Domain Modeling

On this page (20 sections)

1. Identity, Tier & Maturity Profile#

L1 Domain & Query ModelingStableMaintenance: ActiveAOT: FullMIT LicenseConfidence: HIGH
DomainApplicationnet8.0net9.0net10.0

2. Value Proposition & Problem Solved#

Battle-tested DDD abstractions and shared kernel for Clean Architecture .NET applications.

DDD implementations frequently mix ORM change-tracking, eager domain-event list allocations, and raw primitive IDs across AggregateRoot boundaries.

3. Quick Install#

Primary package: EricksonLopez.SharedKernel

dotnet add package EricksonLopez.SharedKernel --version 4.0.0
Also published in this family:
EricksonLopez.SharedKernel.TestingEricksonLopez.SharedKernel.OpenTelemetryEricksonLopez.SharedKernel.DapperEricksonLopez.SharedKernel.JsonEricksonLopez.SharedKernel.EntityFrameworkCoreEricksonLopez.SharedKernel.SourceGenerators

4. Verified Ecosystem Metrics#

v4.0.0
NuGet Published Version
v5.0.1
Repo HEAD Version
3,092
NuGet Downloads
8
Packable Packages
188
Public API Members
53
Benchmark Rows (RyuJIT)

Snapshot retrieved UTC: 2026-12-01

5. When to Use & When Not to Use#

When to use

  • You need canonical AggregateRoot<TId>, Entity<TId>, AuditableEntity<TId>, and lazy domain-event collection primitives.
  • You integrate with EricksonLopez.DomainPrimitives and EricksonLopez.Events across EF Core or Dapper.

When NOT to use

  • You only need standalone scalar value objects without Entity/AggregateRoot lifecycle—use DomainPrimitives or ValueObjects.

6. Core Capabilities & Design Invariants#

Lazy Domain Event Storage

Zero heap allocation for domain-event lists on read-only hydration paths until an event is actually raised.

EF Core & Dapper Integration

Includes SaveChanges domain-event interceptor and source-generated Dapper type handlers for StrongIds.

7. Included NuGet Packages & Adapters#

Package IDStatusNuGet / LocalTFMsAOT StatusDownloadsDescription
EricksonLopez.SharedKernelPrimaryPublishedv4.0.0 / v5.0.1net8.0, net9.0, net10.0AOT: Full1,342A minimal Shared Kernel for DDD-based .NET applications. Provides zero-dependency, AOT-compatible domain primitives: Entity<TId>, AggregateRoot<TId>, DomainEvent, and OperationTimeContext. Designed for Clean Architecture and CQRS. NativeAOT and Trimming compatible on all supported TFMs.
EricksonLopez.SharedKernel.TestingPublishedv4.0.0 / v5.0.1net8.0, net9.0, net10.0AOT: Full308Testing SDK for EricksonLopez.SharedKernel. Provides domain event collectors, assertions, and test helpers for aggregate roots.
EricksonLopez.SharedKernel.OpenTelemetryPublishedv4.0.0 / v5.0.1net8.0, net9.0, net10.0AOT: Full306OpenTelemetry tracing and metrics instrumentation for EricksonLopez.SharedKernel domain events. NativeAOT and Trimming compatible.
EricksonLopez.SharedKernel.DapperPublishedv4.0.0 / v5.0.1net8.0, net9.0, net10.0AOT: Full302Dapper TypeHandler adapters and registration extensions for EricksonLopez.SharedKernel strong identifiers.
EricksonLopez.SharedKernel.JsonPublishedv4.0.0 / v5.0.1net8.0, net9.0, net10.0AOT: Full288System.Text.Json dynamic converter factory and serialization adapters for EricksonLopez.SharedKernel strong identifiers.
EricksonLopez.SharedKernel.EntityFrameworkCorePublishedv4.0.0 / v5.0.1net8.0, net9.0, net10.0AOT: Full272Entity Framework Core integration for EricksonLopez.SharedKernel. Provides NativeAOT-ready StrongId value converters, DomainEventsInterceptor for automatic event draining on SaveChanges, and ModelBuilder conventions.
EricksonLopez.SharedKernel.SourceGeneratorsAnalyzer / GeneratorPublishedv4.0.0 / v5.0.1netstandard2.0AOT: N/A (Analyzer/Legacy)274Roslyn Incremental Source Generators for EricksonLopez.SharedKernel. Generates zero-reflection, Native AOT-safe Dapper bulk registrations and domain metadata.
EricksonLopez.SharedKernel.PersistenceUnpublished— / v5.0.1net8.0, net9.0, net10.0AOT: Full0Compile-time persistence metadata attributes and entity descriptors for EricksonLopez.SharedKernel.

8. Quick Start Code Example#

Grounded in verified public APIs from EricksonLopez.SharedKernel. Compile with `<ImplicitUsings>disable</ImplicitUsings>` and explicit imports.

using System;
using EricksonLopez.SharedKernel;

public readonly record struct OrderId(Guid Value);

public sealed record OrderPlacedEvent(OrderId OrderId, decimal TotalAmount) : DomainEvent;

public sealed class Order : AggregateRoot<OrderId>
{
    public decimal TotalAmount { get; private set; }

    private Order(OrderId id, decimal totalAmount) : base(id)
    {
        TotalAmount = totalAmount;
    }

    public static Order Place(OrderId id, decimal totalAmount)
    {
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(totalAmount);
        var order = new Order(id, totalAmount);
        order.RaiseDomainEvent(new OrderPlacedEvent(id, totalAmount));
        return order;
    }
}

9. Architecture & Dependency Flow#

flowchart LR
  lib_shared_kernel["EricksonLopez.SharedKernel (L1)"]
  lib_domain_primitives["EricksonLopez.DomainPrimitives (L0)"]
  lib_shared_kernel --> lib_domain_primitives
  lib_events["EricksonLopez.Events (L0)"]
  lib_shared_kernel --> lib_events
EricksonLopez.SharedKernel Dependency Topology2 upstream library dependencies and 0 downstream dependent libraries verified in dependencies.json.
View accessible text summary and structure

2 upstream library dependencies and 0 downstream dependent libraries verified in dependencies.json.

DirectionLibraryTierRelationship Kinds
UpstreamEricksonLopez.DomainPrimitivesL0Adapter, Compile-Time, NuGet Package
UpstreamEricksonLopez.EventsL0Compile-Time, NuGet Package
flowchart LR
  lib_shared_kernel["EricksonLopez.SharedKernel (L1)"]
  lib_domain_primitives["EricksonLopez.DomainPrimitives (L0)"]
  lib_shared_kernel --> lib_domain_primitives
  lib_events["EricksonLopez.Events (L0)"]
  lib_shared_kernel --> lib_events

10. Target Frameworks & Native AOT / Trimming Matrix#

MSBuild `.csproj` inspection across 8 packages: 7 Full, 0 Partial, 0 Incompatible, 1 NotApplicable (analyzers/generators).

Package IDIsAotCompatibleEnableTrimAnalyzerVerified AOT StatusTarget Frameworks
EricksonLopez.SharedKerneltruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.SharedKernel.TestingtruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.SharedKernel.OpenTelemetrytruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.SharedKernel.DappertruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.SharedKernel.JsontruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.SharedKernel.EntityFrameworkCoretruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.SharedKernel.SourceGeneratorsnullfalseNotApplicablenetstandard2.0
EricksonLopez.SharedKernel.PersistencetruetrueFullnet8.0, net9.0, net10.0

11. Upstream Dependencies & Downstream Dependents#

Upstream Dependencies (2)

Downstream Dependents (0)

No other EricksonLopez.* libraries currently depend on this family.

12. Optional Adapters & Third-Party Integrations#

Internal Adapter Edges & Integration Packages

Verified External NuGet Dependencies (4)

DapperMicrosoft.EntityFrameworkCoreMicrosoft.Extensions.DependencyInjection.AbstractionsOpenTelemetry.Api

13. Configuration & DI Registration Summary#

Verified DI & Configuration Entry Points

  • SharedKernelModelConfigurationExtensions.ConfigureStrongId<TId, TValue>

    Configures a `StrongIdValueConverter<TId, TValue>` for the specified strongly-typed identifier type.

  • SharedKernelModelConfigurationExtensions.ConfigureStrongIdsFromAssemblies

    Scans multiple assemblies and configures value converters for all concrete types implementing `IStrongId<TSelf, TValue>`.

  • SharedKernelModelConfigurationExtensions.ConfigureStrongIdsFromAssembly

    Scans the specified assembly and configures value converters for all concrete types implementing `IStrongId<TSelf, TValue>`.

  • SharedKernelEntityFrameworkServiceCollectionExtensions.AddSharedKernelDomainEventsInterceptor

    Registers the `DomainEventsInterceptor` as a scoped `ISaveChangesInterceptor` in the service collection.

  • SharedKernelEntityFrameworkServiceCollectionExtensions.AddSharedKernelDomainEventsInterceptor<TDispatcher>

    Registers a concrete `IDomainEventDispatcher` implementation and the `DomainEventsInterceptor` as scoped services in the service collection.

  • SharedKernelOpenTelemetryExtensions.AddSharedKernelInstrumentation

    Adds the SharedKernel diagnostic `Metrics.Meter` to the meter provider builder.

Key Public Types & Contracts

  • EricksonLopez.SharedKernel.AggregateRoot`1 (class)

    Represents an abstract base class for aggregate roots that define transactional consistency boundaries in Domain-Driven Design.

  • EricksonLopez.SharedKernel.AuditableAggregateRoot`1 (class)

    Represents an abstract base class for aggregate roots that track temporal and actor audit metadata.

  • EricksonLopez.SharedKernel.AuditableEntity`1 (class)

    Represents an abstract base class for domain entities that track temporal and actor audit metadata.

  • EricksonLopez.SharedKernel.DomainEvent (record)

    Represents an abstract base record for immutable domain events.

  • EricksonLopez.SharedKernel.DomainEventIdentityEqualityComparer (class)

    Provides equality comparison for domain events based strictly on their unique identifier (`DomainEvent.Id`).

  • EricksonLopez.SharedKernel.Entity`1 (class)

    Represents an abstract base class for domain entities whose equality is determined by runtime type and identity.

  • EricksonLopez.SharedKernel.IAggregateRoot (interface)

    Defines an aggregate root that acts as the transactional consistency boundary of a domain model.

  • EricksonLopez.SharedKernel.IAuditableEntity (interface)

    Defines temporal and actor audit metadata for entities and aggregate roots.

  • EricksonLopez.SharedKernel.IDomainEventDispatcher (interface)

    Defines the contract for dispatching domain events collected from domain entities.

  • EricksonLopez.SharedKernel.IEntity (interface)

    Defines a non-generic marker contract for domain entities.

  • EricksonLopez.SharedKernel.IEntityId (interface)

    Defines the non-generic contract for Guid-backed strongly-typed domain entity identifiers.

  • EricksonLopez.SharedKernel.IEntityId`1 (interface)

    Defines the generic contract for Guid-backed strongly-typed domain entity identifiers supporting zero-reflection instantiation.

14. Verified Performance Benchmarks#

All verified measurements below come strictly from `BenchmarkDotNet.Artifacts` running on .NET RyuJIT (0 NativeAOT benchmark runs exist in this snapshot).

Total rows: 53 · Measured: 22 · NA / Error: 31 · Suites: 4

Observed runtimes: .NET 10.0.10 X64 RyuJIT x86-64-v4 · .NET 10.0.12 X64 RyuJIT x86-64-v4 · .NET 8.0 (JIT) · .NET 9.0 (JIT)

Observed CPUs: AMD EPYC 9V45 4.49GHz, 1 CPU, 4 logical and 2 physical cores · AMD Ryzen 7 9800X3D 4.70GHz, 1 CPU, 8 logical and 8 physical cores

SuiteMethodRuntimeMean (ns)Allocated (B)Status
EntityComparisonBenchmarksArdalis_EntityEquality_SameId.NET 10.0.12 X64 RyuJIT x86-64-v40.0020measured
EntityComparisonBenchmarksEricksonLopez_EntityEquality_DifferentId.NET 10.0.12 X64 RyuJIT x86-64-v40.0020measured
SharedKernelBenchmarksResultSuccess.NET 10.0.10 X64 RyuJIT x86-64-v40.0040measured
SharedKernelBenchmarksAggregateDomainEventsAccessNoEvents.NET 10.0.10 X64 RyuJIT x86-64-v40.0110measured
SharedKernelBenchmarksEntityEquality_DifferentId.NET 10.0.12 X64 RyuJIT x86-64-v40.0140measured
SharedKernelBenchmarksEntityEquality_SameId.NET 10.0.12 X64 RyuJIT x86-64-v40.0170measured
EntityComparisonBenchmarksArdalis_EntityEquality_DifferentId.NET 10.0.12 X64 RyuJIT x86-64-v40.0410measured
EntityComparisonBenchmarksEricksonLopez_EntityEquality_SameId.NET 10.0.12 X64 RyuJIT x86-64-v40.0440measured
SharedKernelBenchmarksAggregateDrainDomainEvents_NoEvents.NET 10.0.12 X64 RyuJIT x86-64-v40.3430measured
SharedKernelBenchmarksEntityEquality.NET 10.0.10 X64 RyuJIT x86-64-v40.3850measured
SharedKernelBenchmarksResultFailure.NET 10.0.10 X64 RyuJIT x86-64-v40.7970measured
SharedKernelBenchmarksEntityGetHashCode.NET 10.0.12 X64 RyuJIT x86-64-v43.2140measured
AggregateHydrationBenchmarksEricksonLopez_AggregateHydration_ZeroEvents.NET 10.0.12 X64 RyuJIT x86-64-v43.640measured
AggregateHydrationBenchmarksArdalis_AggregateHydration_ZeroEvents.NET 10.0.12 X64 RyuJIT x86-64-v48.7372measured
AggregateHydrationBenchmarksEricksonLopez_DrainEvents_WithEvents.NET 10.0.12 X64 RyuJIT x86-64-v416.132112measured
SharedKernelBenchmarksAggregateDrainDomainEvents_WithEvents.NET 10.0.12 X64 RyuJIT x86-64-v417.221112measured
SharedKernelBenchmarksAggregateRaiseDomainEvent_FirstTime.NET 10.0.12 X64 RyuJIT x86-64-v418.168128measured
AggregateHydrationBenchmarksArdalis_DrainEvents_WithEvents.NET 10.0.12 X64 RyuJIT x86-64-v443.889200measured
ResultBenchmarksCreateFailure.NET 10.0.10 X64 RyuJIT x86-64-v4169,10032measured
ResultBenchmarksCreateSuccess.NET 10.0.10 X64 RyuJIT x86-64-v4199,1000measured
ResultBenchmarksSyncPipeline_Tap.NET 10.0.10 X64 RyuJIT x86-64-v4303,3000measured
ResultBenchmarksAsyncPipeline_Tap.NET 10.0.10 X64 RyuJIT x86-64-v42,621,100248measured

15. Release History & NuGet vs Repo Status#

Version lag detected: NuGet.org latest published version is v4.0.0, while local repository HEAD is at v5.0.1.

VersionSourcePublished DateSummary
v4.0.0 ↗nuget2026-09-21Published EricksonLopez.SharedKernel 4.0.0 to NuGet.org.
v4.0.0 ↗github2026-09-21Ecosystem Packages in this release - `EricksonLopez.SharedKernel` - `EricksonLopez.SharedKernel.EntityFrameworkCore` - `EricksonLopez.SharedKernel.Dapper` - `EricksonLopez.SharedKernel.Json` - `EricksonLopez.SharedKernel.SourceGenerators` - `EricksonLopez.SharedKernel.OpenTelemetry` - `EricksonLopez.SharedKernel.Testing`
v3.0.0 ↗nuget2026-08-25Published EricksonLopez.SharedKernel 3.0.0 to NuGet.org.
v3.0.0 ↗github2026-08-25Ecosystem Packages in this release - `EricksonLopez.SharedKernel` - `EricksonLopez.SharedKernel.EntityFrameworkCore` - `EricksonLopez.SharedKernel.Dapper` - `EricksonLopez.SharedKernel.Json` - `EricksonLopez.SharedKernel.SourceGenerators` - `EricksonLopez.SharedKernel.OpenTelemetry` - `EricksonLopez.SharedKernel.Testing`
v2.0.0 ↗nuget2026-08-12Published EricksonLopez.SharedKernel 2.0.0 to NuGet.org.
v2.0.0 ↗github2026-08-12Products in this release - **EricksonLopez.SharedKernel** `2.0.0` – [CHANGELOG](https://github.com/ericksonlopezf/dotnet-shared-kernel/blob/v2.0.0/CHANGELOG.md) --- For detailed changes, see the linked changelog above.
v1.1.0 ↗github2026-07-23Products in this release - **EricksonLopez.SharedKernel** `1.1.0` – [CHANGELOG](https://github.com/ericksonlopezf/dotnet-shared-kernel/blob/v1.1.0/CHANGELOG.md) --- For detailed changes, see the linked changelog above. Installation ```bash dotnet add package EricksonLopez.SharedKernel --version 1.1.0 ```
v1.1.0 ↗nuget2026-07-23Published EricksonLopez.SharedKernel 1.1.0 to NuGet.org.
v1.0.1 ↗github2026-07-21See [CHANGELOG.md](https://github.com/ericksonlopezf/dotnet-shared-kernel/blob/main/CHANGELOG.md) for details.
v1.0.1 ↗nuget2026-07-21Published EricksonLopez.SharedKernel 1.0.1 to NuGet.org.
v1.0.0 ↗github2026-07-16See [CHANGELOG.md](https://github.com/ericksonlopezf/dotnet-shared-kernel/blob/main/CHANGELOG.md) for details.
v1.0.0 ↗nuget2026-07-16Published EricksonLopez.SharedKernel 1.0.0 to NuGet.org.

Libraries in the same tier, architectural layer, or directly paired via dependency edges.

17. Documentation, API Reference & Portal Links#

Per-library conceptual Starlight pages expand in M4; API Reference pages expand in M3.2.

18. Source Repository, License & Contributing#

Released under the MIT License. All assemblies follow EricksonLopez.* build invariants: explicit imports, strong-name signing (`EricksonLopez.snk`), and ASCII author metadata (`Erickson Lopez`).

19. Troubleshooting, Pitfalls & Migration Guidance#

  • Register ConfigureStrongIdsFromAssembly in EF Core model configuration so strongly typed IDs map cleanly without runtime reflection.
  • Version lag detected: NuGet.org latest published version is v4.0.0, while local repository HEAD is at v5.0.1.

20. Quality & Verification Evidence#

Strong-Name Signing (`EricksonLopez.snk`)
EricksonLopez.snk
`ImplicitUsings=disable`
disable
XML Documentation Extraction
Verified (10 namespaces, 47 types, 188 members)
MSBuild AOT / Trim Attributes
7 Full / 0 Partial / 0 Incompatible / 1 N/A
BenchmarkDotNet Artifacts
53 total (22 measured, 31 na_error)

Explicit Verification Boundaries & Limitations

  • All verified measurements below come strictly from `BenchmarkDotNet.Artifacts` running on .NET RyuJIT (0 NativeAOT benchmark runs exist in this snapshot).
  • 1 unpublished

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.