EricksonLopez.SharedKernel
dotnet-shared-kernel · Domain Modeling
On this page (20 sections)
1. Identity, Tier & Maturity Profile#
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
4. Verified Ecosystem Metrics#
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 ID | Status | NuGet / Local | TFMs | AOT Status | Downloads | Description |
|---|---|---|---|---|---|---|
| EricksonLopez.SharedKernelPrimary | Published | v4.0.0 / v5.0.1 | net8.0, net9.0, net10.0 | AOT: Full | 1,342 | A 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.Testing | Published | v4.0.0 / v5.0.1 | net8.0, net9.0, net10.0 | AOT: Full | 308 | Testing SDK for EricksonLopez.SharedKernel. Provides domain event collectors, assertions, and test helpers for aggregate roots. |
| EricksonLopez.SharedKernel.OpenTelemetry | Published | v4.0.0 / v5.0.1 | net8.0, net9.0, net10.0 | AOT: Full | 306 | OpenTelemetry tracing and metrics instrumentation for EricksonLopez.SharedKernel domain events. NativeAOT and Trimming compatible. |
| EricksonLopez.SharedKernel.Dapper | Published | v4.0.0 / v5.0.1 | net8.0, net9.0, net10.0 | AOT: Full | 302 | Dapper TypeHandler adapters and registration extensions for EricksonLopez.SharedKernel strong identifiers. |
| EricksonLopez.SharedKernel.Json | Published | v4.0.0 / v5.0.1 | net8.0, net9.0, net10.0 | AOT: Full | 288 | System.Text.Json dynamic converter factory and serialization adapters for EricksonLopez.SharedKernel strong identifiers. |
| EricksonLopez.SharedKernel.EntityFrameworkCore | Published | v4.0.0 / v5.0.1 | net8.0, net9.0, net10.0 | AOT: Full | 272 | Entity 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 / Generator | Published | v4.0.0 / v5.0.1 | netstandard2.0 | AOT: N/A (Analyzer/Legacy) | 274 | Roslyn Incremental Source Generators for EricksonLopez.SharedKernel. Generates zero-reflection, Native AOT-safe Dapper bulk registrations and domain metadata. |
| EricksonLopez.SharedKernel.Persistence | Unpublished | — / v5.0.1 | net8.0, net9.0, net10.0 | AOT: Full | 0 | Compile-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#
Rendering diagram…
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
View accessible text summary and structure
2 upstream library dependencies and 0 downstream dependent libraries verified in dependencies.json.
| Direction | Library | Tier | Relationship Kinds |
|---|---|---|---|
| Upstream | EricksonLopez.DomainPrimitives | L0 | Adapter, Compile-Time, NuGet Package |
| Upstream | EricksonLopez.Events | L0 | Compile-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_events10. Target Frameworks & Native AOT / Trimming Matrix#
MSBuild `.csproj` inspection across 8 packages: 7 Full, 0 Partial, 0 Incompatible, 1 NotApplicable (analyzers/generators).
| Package ID | IsAotCompatible | EnableTrimAnalyzer | Verified AOT Status | Target Frameworks |
|---|---|---|---|---|
| EricksonLopez.SharedKernel | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SharedKernel.Testing | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SharedKernel.OpenTelemetry | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SharedKernel.Dapper | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SharedKernel.Json | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SharedKernel.EntityFrameworkCore | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SharedKernel.SourceGenerators | null | false | NotApplicable | netstandard2.0 |
| EricksonLopez.SharedKernel.Persistence | true | true | Full | net8.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
- EricksonLopez.SharedKernel.Dapper→ EricksonLopez.DomainPrimitives.Abstractions (EricksonLopez.DomainPrimitives)
Verified External NuGet Dependencies (4)
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.ConfigureStrongIdsFromAssembliesScans multiple assemblies and configures value converters for all concrete types implementing `IStrongId<TSelf, TValue>`.
SharedKernelModelConfigurationExtensions.ConfigureStrongIdsFromAssemblyScans the specified assembly and configures value converters for all concrete types implementing `IStrongId<TSelf, TValue>`.
SharedKernelEntityFrameworkServiceCollectionExtensions.AddSharedKernelDomainEventsInterceptorRegisters 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.AddSharedKernelInstrumentationAdds 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).
| Suite | Method | Runtime | Mean (ns) | Allocated (B) | Status |
|---|---|---|---|---|---|
| EntityComparisonBenchmarks | Ardalis_EntityEquality_SameId | .NET 10.0.12 X64 RyuJIT x86-64-v4 | 0.002 | 0 | measured |
| EntityComparisonBenchmarks | EricksonLopez_EntityEquality_DifferentId | .NET 10.0.12 X64 RyuJIT x86-64-v4 | 0.002 | 0 | measured |
| SharedKernelBenchmarks | ResultSuccess | .NET 10.0.10 X64 RyuJIT x86-64-v4 | 0.004 | 0 | measured |
| SharedKernelBenchmarks | AggregateDomainEventsAccessNoEvents | .NET 10.0.10 X64 RyuJIT x86-64-v4 | 0.011 | 0 | measured |
| SharedKernelBenchmarks | EntityEquality_DifferentId | .NET 10.0.12 X64 RyuJIT x86-64-v4 | 0.014 | 0 | measured |
| SharedKernelBenchmarks | EntityEquality_SameId | .NET 10.0.12 X64 RyuJIT x86-64-v4 | 0.017 | 0 | measured |
| EntityComparisonBenchmarks | Ardalis_EntityEquality_DifferentId | .NET 10.0.12 X64 RyuJIT x86-64-v4 | 0.041 | 0 | measured |
| EntityComparisonBenchmarks | EricksonLopez_EntityEquality_SameId | .NET 10.0.12 X64 RyuJIT x86-64-v4 | 0.044 | 0 | measured |
| SharedKernelBenchmarks | AggregateDrainDomainEvents_NoEvents | .NET 10.0.12 X64 RyuJIT x86-64-v4 | 0.343 | 0 | measured |
| SharedKernelBenchmarks | EntityEquality | .NET 10.0.10 X64 RyuJIT x86-64-v4 | 0.385 | 0 | measured |
| SharedKernelBenchmarks | ResultFailure | .NET 10.0.10 X64 RyuJIT x86-64-v4 | 0.797 | 0 | measured |
| SharedKernelBenchmarks | EntityGetHashCode | .NET 10.0.12 X64 RyuJIT x86-64-v4 | 3.214 | 0 | measured |
| AggregateHydrationBenchmarks | EricksonLopez_AggregateHydration_ZeroEvents | .NET 10.0.12 X64 RyuJIT x86-64-v4 | 3.6 | 40 | measured |
| AggregateHydrationBenchmarks | Ardalis_AggregateHydration_ZeroEvents | .NET 10.0.12 X64 RyuJIT x86-64-v4 | 8.73 | 72 | measured |
| AggregateHydrationBenchmarks | EricksonLopez_DrainEvents_WithEvents | .NET 10.0.12 X64 RyuJIT x86-64-v4 | 16.132 | 112 | measured |
| SharedKernelBenchmarks | AggregateDrainDomainEvents_WithEvents | .NET 10.0.12 X64 RyuJIT x86-64-v4 | 17.221 | 112 | measured |
| SharedKernelBenchmarks | AggregateRaiseDomainEvent_FirstTime | .NET 10.0.12 X64 RyuJIT x86-64-v4 | 18.168 | 128 | measured |
| AggregateHydrationBenchmarks | Ardalis_DrainEvents_WithEvents | .NET 10.0.12 X64 RyuJIT x86-64-v4 | 43.889 | 200 | measured |
| ResultBenchmarks | CreateFailure | .NET 10.0.10 X64 RyuJIT x86-64-v4 | 169,100 | 32 | measured |
| ResultBenchmarks | CreateSuccess | .NET 10.0.10 X64 RyuJIT x86-64-v4 | 199,100 | 0 | measured |
| ResultBenchmarks | SyncPipeline_Tap | .NET 10.0.10 X64 RyuJIT x86-64-v4 | 303,300 | 0 | measured |
| ResultBenchmarks | AsyncPipeline_Tap | .NET 10.0.10 X64 RyuJIT x86-64-v4 | 2,621,100 | 248 | measured |
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.
| Version | Source | Published Date | Summary |
|---|---|---|---|
| v4.0.0 ↗ | nuget | 2026-09-21 | Published EricksonLopez.SharedKernel 4.0.0 to NuGet.org. |
| v4.0.0 ↗ | github | 2026-09-21 | Ecosystem 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 ↗ | nuget | 2026-08-25 | Published EricksonLopez.SharedKernel 3.0.0 to NuGet.org. |
| v3.0.0 ↗ | github | 2026-08-25 | Ecosystem 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 ↗ | nuget | 2026-08-12 | Published EricksonLopez.SharedKernel 2.0.0 to NuGet.org. |
| v2.0.0 ↗ | github | 2026-08-12 | Products 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 ↗ | github | 2026-07-23 | Products 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 ↗ | nuget | 2026-07-23 | Published EricksonLopez.SharedKernel 1.1.0 to NuGet.org. |
| v1.0.1 ↗ | github | 2026-07-21 | See [CHANGELOG.md](https://github.com/ericksonlopezf/dotnet-shared-kernel/blob/main/CHANGELOG.md) for details. |
| v1.0.1 ↗ | nuget | 2026-07-21 | Published EricksonLopez.SharedKernel 1.0.1 to NuGet.org. |
| v1.0.0 ↗ | github | 2026-07-16 | See [CHANGELOG.md](https://github.com/ericksonlopezf/dotnet-shared-kernel/blob/main/CHANGELOG.md) for details. |
| v1.0.0 ↗ | nuget | 2026-07-16 | Published EricksonLopez.SharedKernel 1.0.0 to NuGet.org. |
16. Complementary & Related Libraries#
Libraries in the same tier, architectural layer, or directly paired via dependency edges.
17. Documentation, API Reference & Portal Links#
Conceptual Documentation (Starlight) →
Extracted XML API Reference →
10 namespaces · 47 types · 188 members
Ecosystem Dependency Map →
Learning Center & Handbook →
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