EricksonLopez.SharedKernel
dotnet-shared-kernel · Modelado de Dominio
En esta página (20 secciones)
1. Identidad, Nivel y Perfil de Madurez#
2. Propuesta de Valor y Problema que Resuelve#
Battle-tested DDD abstractions and shared kernel for Clean Architecture .NET applications.
Las implementaciones DDD suelen acoplar rastreo de ORM, asignaciones innecesarias de listas de eventos e IDs primitivos sin tipado fuerte en los agregados.
3. Instalación Rápida#
Paquete principal: EricksonLopez.SharedKernel
4. Métricas Verificadas del Ecosistema#
Instantánea recuperada UTC: 2026-12-01
5. Cuándo Usar y Cuándo NO Usar#
Cuándo usar
- Necesitas clases base AggregateRoot<TId>, Entity<TId>, AuditableEntity<TId> y almacenamiento diferido de eventos de dominio.
- Integras EricksonLopez.DomainPrimitives y EricksonLopez.Events con EF Core o Dapper.
Cuándo NO usar
- Solo requieres value objects aislados sin ciclo de vida Entity/AggregateRoot; usa DomainPrimitives o ValueObjects.
6. Capacidades Principales e Invariantes de Diseño#
Almacenamiento Diferido de Eventos
Cero asignaciones de listas de eventos durante la hidratación de solo lectura hasta que se emite un evento.
Integración con EF Core y Dapper
Incluye interceptor SaveChanges para eventos de dominio y type handlers de Dapper generados en compilación para StrongIds.
7. Paquetes NuGet y Adaptadores Incluidos#
| ID del Paquete | Estado | NuGet / Local | TFMs | Estado AOT | Descargas | Descripción |
|---|---|---|---|---|---|---|
| EricksonLopez.SharedKernelPrincipal | Publicado | v4.0.0 / v5.0.1 | net8.0, net9.0, net10.0 | AOT: Completo | 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 | Publicado | v4.0.0 / v5.0.1 | net8.0, net9.0, net10.0 | AOT: Completo | 308 | Testing SDK for EricksonLopez.SharedKernel. Provides domain event collectors, assertions, and test helpers for aggregate roots. |
| EricksonLopez.SharedKernel.OpenTelemetry | Publicado | v4.0.0 / v5.0.1 | net8.0, net9.0, net10.0 | AOT: Completo | 306 | OpenTelemetry tracing and metrics instrumentation for EricksonLopez.SharedKernel domain events. NativeAOT and Trimming compatible. |
| EricksonLopez.SharedKernel.Dapper | Publicado | v4.0.0 / v5.0.1 | net8.0, net9.0, net10.0 | AOT: Completo | 302 | Dapper TypeHandler adapters and registration extensions for EricksonLopez.SharedKernel strong identifiers. |
| EricksonLopez.SharedKernel.Json | Publicado | v4.0.0 / v5.0.1 | net8.0, net9.0, net10.0 | AOT: Completo | 288 | System.Text.Json dynamic converter factory and serialization adapters for EricksonLopez.SharedKernel strong identifiers. |
| EricksonLopez.SharedKernel.EntityFrameworkCore | Publicado | v4.0.0 / v5.0.1 | net8.0, net9.0, net10.0 | AOT: Completo | 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.SourceGeneratorsAnalizador / Generador | Publicado | v4.0.0 / v5.0.1 | netstandard2.0 | AOT: N/A (Analizador/Legado) | 274 | Roslyn Incremental Source Generators for EricksonLopez.SharedKernel. Generates zero-reflection, Native AOT-safe Dapper bulk registrations and domain metadata. |
| EricksonLopez.SharedKernel.Persistence | No publicado | — / v5.0.1 | net8.0, net9.0, net10.0 | AOT: Completo | 0 | Compile-time persistence metadata attributes and entity descriptors for EricksonLopez.SharedKernel. |
8. Ejemplo Quick Start#
Basado en APIs públicas verificadas de EricksonLopez.SharedKernel. Compila con `<ImplicitUsings>disable</ImplicitUsings>` e importaciones explícitas.
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. Arquitectura y Flujo de Dependencias#
Renderizando diagrama…
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
Ver descripción textual y tabla accesible
2 dependencias hacia librerías aguas arriba y 0 librerías dependientes aguas abajo verificadas en dependencies.json.
| Dirección | Librería | Nivel | Tipos de Relación |
|---|---|---|---|
| Aguas arriba | EricksonLopez.DomainPrimitives | L0 | Adaptador, Tiempo de compilación, Paquete NuGet |
| Aguas arriba | EricksonLopez.Events | L0 | Tiempo de compilación, Paquete NuGet |
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 y Matriz Native AOT / Trimming#
Inspección MSBuild `.csproj` sobre 8 paquetes: 7 Full, 0 Partial, 0 Incompatible, 1 NotApplicable (analizadores/generadores).
| ID del Paquete | IsAotCompatible | EnableTrimAnalyzer | Estado AOT Verificado | 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. Dependencias Aguas Arriba y Dependientes Aguas Abajo#
Dependencias Aguas Arriba (2)
Dependientes Aguas Abajo (0)
Ninguna otra librería EricksonLopez.* depende actualmente de esta familia.
12. Adaptadores Opcionales e Integraciones Externas#
Aristas de Adaptadores Internos y Paquetes de Integración
- EricksonLopez.SharedKernel.Dapper→ EricksonLopez.DomainPrimitives.Abstractions (EricksonLopez.DomainPrimitives)
Dependencias NuGet Externas Verificadas (4)
13. Resumen de Configuración y Registro en DI#
Puntos de Entrada DI y Configuración Verificados
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.
Tipos Públicos y Contratos Clave
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. Benchmarks de Rendimiento Verificados#
Todas las mediciones verificadas provienen estrictamente de `BenchmarkDotNet.Artifacts` ejecutados sobre .NET RyuJIT (existen 0 ejecuciones NativeAOT en esta instantánea).
| Suite | Método | Runtime | Media (ns) | Asignado (B) | Estado |
|---|---|---|---|---|---|
| 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. Historial de Versiones y Estado NuGet vs Repositorio#
Desfase de versiones detectado: la última versión publicada en NuGet.org es v4.0.0, mientras el HEAD del repositorio local está en v5.0.1.
| Versión | Origen | Fecha de Publicación | Resumen |
|---|---|---|---|
| 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. Librerías Complementarias y Relacionadas#
Librerías en el mismo nivel, capa arquitectónica o vinculadas directamente mediante aristas de dependencia.
17. Documentación, API Reference y Enlaces del Portal#
Documentación Conceptual (Starlight) →
Referencia de API XML Extraída →
10 namespaces · 47 tipos · 188 miembros
Mapa de Dependencias del Ecosistema →
Centro de Aprendizaje y Manual →
Las páginas conceptuales por librería en Starlight se completan en M4; las páginas de API Reference en M3.2.
18. Repositorio Fuente, Licencia y Contribución#
Publicado bajo Licencia MIT. Todos los ensamblados cumplen los invariantes de compilación EricksonLopez.*: importaciones explícitas, firma fuerte (`EricksonLopez.snk`) y metadatos de autor en ASCII (`Erickson Lopez`).
19. Resolución de Problemas, Riesgos y Migración#
- Registra ConfigureStrongIdsFromAssembly en la configuración del modelo EF Core para mapear StrongIds sin reflexión en tiempo de ejecución.
- Desfase de versiones detectado: la última versión publicada en NuGet.org es v4.0.0, mientras el HEAD del repositorio local está en v5.0.1.
20. Evidencia de Calidad y Verificación#
- Firma Fuerte (`EricksonLopez.snk`)
- EricksonLopez.snk
- `ImplicitUsings=disable`
- disable
- Extracción de Documentación XML
- Verificado (10 namespaces, 47 tipos, 188 miembros)
- Atributos MSBuild AOT / Trimming
- 7 Full / 0 Partial / 0 Incompatible / 1 N/A
- Artefactos BenchmarkDotNet
- 53 total (22 measured, 31 na_error)
Límites Explícitos de Verificación y Alcance
- Todas las mediciones verificadas provienen estrictamente de `BenchmarkDotNet.Artifacts` ejecutados sobre .NET RyuJIT (existen 0 ejecuciones NativeAOT en esta instantánea).
- 1 no publicados