EricksonLopez.DomainPrimitives
dotnet-domain-primitives · Domain Modeling
On this page (20 sections)
1. Identity, Tier & Maturity Profile#
2. Value Proposition & Problem Solved#
High-performance, AOT-ready Domain Primitives for .NET 8+. Generates secure, immutable value objects with deep BCL integration, including IUtf8SpanParsable, for robust domain modeling with minimal overhead.
Using raw string, Guid, int, or decimal values across domain boundaries lets invalid, unnormalized, or transposed identifiers pass undetected and scatters defensive checks across services and repositories.
3. Quick Install#
Primary package: EricksonLopez.DomainPrimitives
dotnet add package EricksonLopez.DomainPrimitives --version 3.0.0<PackageReference Include="EricksonLopez.DomainPrimitives" Version="3.0.0" /><PackageVersion Include="EricksonLopez.DomainPrimitives" Version="3.0.0" />4. Verified Ecosystem Metrics#
Snapshot retrieved UTC: 2026-12-01
5. When to Use & When Not to Use#
When to use
- You want compile-time StrongIds, SmartEnums, and validated string/numeric primitives with Roslyn source generation.
- You require BCL span parsing (IParsable<T>, ISpanParsable<T>, IUtf8SpanParsable<T>) and EF Core or Dapper adapters.
When NOT to use
- You need composite multi-field domain types such as Money with CurrencyCode or regional tax identifiers—use EricksonLopez.ValueObjects instead.
- Your project only needs minimal pass-through DTOs without domain invariants.
6. Core Capabilities & Design Invariants#
Stack-Allocated Value Types
Generates readonly record struct primitives and StrongIds with zero heap allocation on non-string paths.
Roslyn Source Generators & Analyzers
Emits IParsable<T>, ISpanParsable<T>, IUtf8SpanParsable<T>, and ISpanFormattable plus DP0001–DP0018 compile-time diagnostics.
Semantic Shortcuts & Persistence
Includes built-in attributes ([Email], [CountryCode], [CurrencyCode], [Money]) and EF Core / Dapper registration extensions.
7. Included NuGet Packages & Adapters#
| Package ID | Status | NuGet / Local | TFMs | AOT Status | Downloads | Description |
|---|---|---|---|---|---|---|
| EricksonLopez.DomainPrimitivesPrimary | Published | v3.0.0 / v4.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 525 | The definitive framework for Domain Primitives in .NET. Source-generated, NativeAOT-ready, zero-reflection strong IDs, value objects, validated types, and smart enums. This meta-package includes Abstractions, Source Generators, and Roslyn Analyzers. |
| EricksonLopez.DomainPrimitives.Abstractions | Published | v3.0.0 / v4.1.0 | net8.0, net9.0, net10.0, netstandard2.0 | AOT: Full | 3,352 | Core abstractions for domain primitives: marker interfaces, type declaration attributes, validation attributes, and normalization attributes. Zero dependencies — pure attributes and interfaces only. NativeAOT and trimming compatible. |
| EricksonLopez.DomainPrimitives.OpenApi | Published | v3.0.0 / v4.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 472 | OpenAPI/Swashbuckle integration for EricksonLopez.DomainPrimitives. Generates precise schema specifications for domain primitives. |
| EricksonLopez.DomainPrimitives.AspNetCore | Published | v3.0.0 / v4.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 457 | ASP.NET Core integration for EricksonLopez.DomainPrimitives. Automatically generates ModelBinders and Swagger/OpenAPI schemas for Domain Primitives. |
| EricksonLopez.DomainPrimitives.Dapper | Published | v3.0.0 / v4.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 457 | Dapper integration for EricksonLopez.DomainPrimitives. Automatically generates NativeAOT-ready SqlMapper.TypeHandler implementations for all domain primitives without reflection. |
| EricksonLopez.DomainPrimitives.Testing | Published | v3.0.0 / v4.1.0 | net8.0, net9.0, net10.0 | AOT: Partial | 447 | Testing library for EricksonLopez.DomainPrimitives. Provides Assertions, Builders, and Fakes for unit testing your domain primitives seamlessly with xUnit, NSubstitute and AwesomeAssertions. |
| EricksonLopez.DomainPrimitives.EFCore | Published | v3.0.0 / v4.1.0 | net8.0, net9.0, net10.0 | AOT: Full | 438 | EF Core integration for EricksonLopez.DomainPrimitives. Automatically generates NativeAOT-ready ValueConverters for all domain primitives without reflection. |
| EricksonLopez.DomainPrimitives.NewtonsoftJson | Published | v3.0.0 / v4.1.0 | net8.0, net9.0, net10.0 | AOT: Incompatible | 299 | [LEGACY COMPATIBILITY] Newtonsoft.Json (Json.NET) converters and contract resolver for EricksonLopez.DomainPrimitives. Note: Newtonsoft.Json uses heavy runtime reflection and is not NativeAOT or trimming compatible. |
| EricksonLopez.DomainPrimitives.OpenApi.SourceGeneratorsAnalyzer / Generator | Published | v3.0.0 / v4.1.0 | netstandard2.0 | AOT: N/A (Analyzer/Legacy) | 654 | Source Generators for OpenApi integration with EricksonLopez.DomainPrimitives. |
| EricksonLopez.DomainPrimitives.GeneratorsAnalyzer / Generator | Published | v3.0.0 / v4.1.0 | netstandard2.0 | AOT: N/A (Analyzer/Legacy) | 468 | Incremental Source Generators for EricksonLopez.DomainPrimitives. Generates complete domain primitive implementations at compile time: factory methods, parsing, formatting, equality, operators, and validation. Zero runtime footprint. |
| EricksonLopez.DomainPrimitives.AnalyzersAnalyzer / Generator | Published | v3.0.0 / v4.1.0 | netstandard2.0 | AOT: N/A (Analyzer/Legacy) | 458 | Roslyn Analyzers and Code Fixes for EricksonLopez.DomainPrimitives. Detects misuse at compile time: public constructors, bypassed validation, conflicting attributes, missing partial keywords, and more. |
| EricksonLopez.DomainPrimitives.AspNetCore.SourceGeneratorsAnalyzer / Generator | Published | v3.0.0 / v4.1.0 | netstandard2.0 | AOT: N/A (Analyzer/Legacy) | 440 | Source Generators for ASP.NET Core integration with EricksonLopez.DomainPrimitives. |
| EricksonLopez.DomainPrimitives.Dapper.SourceGeneratorsAnalyzer / Generator | Published | v3.0.0 / v4.1.0 | netstandard2.0 | AOT: N/A (Analyzer/Legacy) | 440 | Source Generators for Dapper integration with EricksonLopez.DomainPrimitives. |
| EricksonLopez.DomainPrimitives.EFCore.SourceGeneratorsAnalyzer / Generator | Published | v3.0.0 / v4.1.0 | netstandard2.0 | AOT: N/A (Analyzer/Legacy) | 438 | Source Generators for EF Core integration with EricksonLopez.DomainPrimitives. |
8. Quick Start Code Example#
Grounded in verified public APIs from EricksonLopez.DomainPrimitives. Compile with `<ImplicitUsings>disable</ImplicitUsings>` and explicit imports.
using EricksonLopez.DomainPrimitives;
CountryIsoCode code = CountryIsoCode.Create(" us "); // "US"
EmailAddress email = EmailAddress.Create("user@example.com");
[StringPrimitive]
[Trim, UpperCase, Length(2, 2)]
public readonly partial record struct CountryIsoCode;
[Email]
public readonly partial record struct EmailAddress;9. Architecture & Dependency Flow#
Rendering diagram…
flowchart LR lib_domain_primitives["EricksonLopez.DomainPrimitives (L0)"] lib_shared_kernel["EricksonLopez.SharedKernel (L1)"] lib_shared_kernel --> lib_domain_primitives lib_value_objects["EricksonLopez.ValueObjects (L1)"] lib_value_objects --> lib_domain_primitives lib_mapper["EricksonLopez.Mapper (L2)"] lib_mapper --> lib_domain_primitives
View accessible text summary and structure
0 upstream library dependencies and 3 downstream dependent libraries verified in dependencies.json.
| Direction | Library | Tier | Relationship Kinds |
|---|---|---|---|
| Downstream | EricksonLopez.SharedKernel | L1 | Adapter, Compile-Time, NuGet Package |
| Downstream | EricksonLopez.ValueObjects | L1 | Compile-Time, NuGet Package |
| Downstream | EricksonLopez.Mapper | L2 | Compile-Time, NuGet Package |
flowchart LR
lib_domain_primitives["EricksonLopez.DomainPrimitives (L0)"]
lib_shared_kernel["EricksonLopez.SharedKernel (L1)"]
lib_shared_kernel --> lib_domain_primitives
lib_value_objects["EricksonLopez.ValueObjects (L1)"]
lib_value_objects --> lib_domain_primitives
lib_mapper["EricksonLopez.Mapper (L2)"]
lib_mapper --> lib_domain_primitives10. Target Frameworks & Native AOT / Trimming Matrix#
MSBuild `.csproj` inspection across 14 packages: 6 Full, 1 Partial, 1 Incompatible, 6 NotApplicable (analyzers/generators).
| Package ID | IsAotCompatible | EnableTrimAnalyzer | Verified AOT Status | Target Frameworks |
|---|---|---|---|---|
| EricksonLopez.DomainPrimitives | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.DomainPrimitives.Abstractions | true | true | Full | net8.0, net9.0, net10.0, netstandard2.0 |
| EricksonLopez.DomainPrimitives.OpenApi | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.DomainPrimitives.AspNetCore | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.DomainPrimitives.Dapper | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.DomainPrimitives.Testing | true | false | Partial | net8.0, net9.0, net10.0 |
| EricksonLopez.DomainPrimitives.EFCore | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.DomainPrimitives.NewtonsoftJson | false | false | Incompatible | net8.0, net9.0, net10.0 |
| EricksonLopez.DomainPrimitives.OpenApi.SourceGenerators | null | null | NotApplicable | netstandard2.0 |
| EricksonLopez.DomainPrimitives.Generators | null | null | NotApplicable | netstandard2.0 |
| EricksonLopez.DomainPrimitives.Analyzers | null | null | NotApplicable | netstandard2.0 |
| EricksonLopez.DomainPrimitives.AspNetCore.SourceGenerators | null | null | NotApplicable | netstandard2.0 |
| EricksonLopez.DomainPrimitives.Dapper.SourceGenerators | null | null | NotApplicable | netstandard2.0 |
| EricksonLopez.DomainPrimitives.EFCore.SourceGenerators | null | null | NotApplicable | netstandard2.0 |
11. Upstream Dependencies & Downstream Dependents#
Upstream Dependencies (0)
Zero cross-family upstream library dependencies (foundational node).
Downstream Dependents (3)
12. Optional Adapters & Third-Party Integrations#
Internal Adapter Edges & Integration Packages
- EricksonLopez.SharedKernel.Dapper (EricksonLopez.SharedKernel)→ EricksonLopez.DomainPrimitives.Abstractions
Verified External NuGet Dependencies (7)
13. Configuration & DI Registration Summary#
Verified DI & Configuration Entry Points
DomainPrimitivesMvcBuilderExtensions.AddDomainPrimitivesModelBindingAdds domain primitive model binding to the service collection.
NewtonsoftJsonExtensions.AddDomainPrimitivesAdds the universal domain primitive JSON converter to the serializer.
Key Public Types & Contracts
EricksonLopez.DomainPrimitives.AgeAttribute (class)Specifies that a struct is an age domain primitive. Equivalent to: `[NumericPrimitive<int>] [PrimitiveRange(0, 150)]`.
EricksonLopez.DomainPrimitives.BirthDateAttribute (class)Specifies that a struct is a birth date domain primitive. Equivalent to: `[DatePrimitive(Kind = DateOnly, PastOnly = true)]`.
EricksonLopez.DomainPrimitives.BusinessDateAttribute (class)Specifies that a struct is a business date domain primitive.
EricksonLopez.DomainPrimitives.CountryCodeAttribute (class)Specifies that a struct is an ISO 3166-1 alpha-2 country code (e.g., "US", "DE"). Equivalent to: `[StringPrimitive] [Trim] [UpperCase] [Length(2, 2)]`.
EricksonLopez.DomainPrimitives.CurrencyCodeAttribute (class)Specifies that a struct is an ISO 4217 currency code (e.g., "USD", "EUR"). Equivalent to: `[StringPrimitive] [Trim] [UpperCase] [Length(3, 3)]`.
EricksonLopez.DomainPrimitives.DatePrimitiveAttribute (class)Specifies that a struct is a date- or time-backed domain primitive.
EricksonLopez.DomainPrimitives.DatePrimitiveKind (enum)Specifies the backing temporal type for a date primitive.
EricksonLopez.DomainPrimitives.DateRangeAttribute (class)Specifies that a struct is a date range domain primitive. Architectural Guidance: In Domain-Driven Design, when modeling a compound interval with both start and end timestamps and cross-property validation (`Start <= End`), prefer creating a compound `[ValueObject]`.
EricksonLopez.DomainPrimitives.DiscountAttribute (class)Specifies that a struct is a discount domain primitive. Equivalent to: `[NumericPrimitive<decimal>] [PrimitiveRange(0, 100)]`.
EricksonLopez.DomainPrimitives.DistanceAttribute (class)Specifies that a struct is a distance domain primitive. Equivalent to: `[NumericPrimitive<double>] [PrimitiveRange(0, double.MaxValue)]`.
EricksonLopez.DomainPrimitives.DomainPrimitiveValidationException (class)Represents the exception thrown when a domain primitive cannot be created due to invalid input.
EricksonLopez.DomainPrimitives.DomainPrimitivesDefaultsAttribute (class)Specifies global default policies for domain primitives generated in this assembly.
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 |
|---|---|---|---|---|---|
| ComparativeBenchmarks | ValueObject_Create | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 0.001 | 0 | measured |
| DomainPrimitiveBenchmarks | RawGuid | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 0.114 | 0 | measured |
| ComparativeBenchmarks | StronglyTypedId_Create | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 0.134 | 0 | measured |
| ComparativeBenchmarks | Meziantou_Create | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 0.164 | 0 | measured |
| ComparativeBenchmarks | Meziantou_Create | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 0.167 | 0 | measured |
| ComparativeBenchmarks | TinyTypes_Create | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 0.171 | 0 | measured |
| ComparativeBenchmarks | StronglyTypedId_Create | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 0.173 | 0 | measured |
| ComparativeBenchmarks | StronglyTypedId_Create | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 0.192 | 0 | measured |
| ComparativeBenchmarks | RawGuid_Create | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 0.216 | 0 | measured |
| ComparativeBenchmarks | TinyTypes_Create | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 0.247 | 0 | measured |
| ComparativeBenchmarks | RawGuid_Create | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 0.253 | 0 | measured |
| ComparativeBenchmarks | Meziantou_Create | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 0.309 | 0 | measured |
| DomainPrimitiveBenchmarks | RawGuid | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 0.314 | 0 | measured |
| DomainPrimitiveBenchmarks | RawGuid | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 0.324 | 0 | measured |
| ComparativeBenchmarks | ValueObject_Create | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 0.325 | 0 | measured |
| ComparativeBenchmarks | ValueObject_Create | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 0.331 | 0 | measured |
| ComparativeBenchmarks | RawGuid_Create | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 0.338 | 0 | measured |
| ComparativeBenchmarks | Dapper_TypeHandler_SetValue | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 0.345 | 0 | measured |
| ComparativeBenchmarks | Vogen_Create | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 0.384 | 0 | measured |
| ComparativeBenchmarks | Vogen_Create | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 0.547 | 0 | measured |
| ComparativeBenchmarks | DomainPrimitives_EqualityCheck | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 0.798 | 0 | measured |
| DomainPrimitiveBenchmarks | PrimitiveGuid | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 0.852 | 0 | measured |
| ComparativeBenchmarks | DomainPrimitives_Create | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 0.87 | 0 | measured |
| ComparativeBenchmarks | EFCore_ValueConverter_ConvertFromProvider | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 0.879 | 0 | measured |
| DomainPrimitiveBenchmarks | PrimitiveGuid | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 0.882 | 0 | measured |
15. Release History & NuGet vs Repo Status#
Version lag detected: NuGet.org latest published version is v3.0.0, while local repository HEAD is at v4.1.0.
| Version | Source | Published Date | Summary |
|---|---|---|---|
| v3.0.0 ↗ | nuget | 2026-09-20 | Published EricksonLopez.DomainPrimitives 3.0.0 to NuGet.org. |
| v3.0.0 ↗ | github | 2026-09-20 | Ecosystem Packages in this release | Package | Version | |---------|---------| | `EricksonLopez.DomainPrimitives.Abstractions` | `3.0.0` | | `EricksonLopez.DomainPrimitives` | `3.0.0` | | `EricksonLopez.DomainPrimitives.Generators` | `3.0.0` | | `EricksonLopez.DomainPrimitives.Analyzers` | `3.0.0` | | `EricksonLopez.DomainPrimitives.AspNetCore` | `3.0.0` | | `EricksonLopez.DomainPrimitives.AspN... |
| v2.0.0 ↗ | nuget | 2026-08-25 | Published EricksonLopez.DomainPrimitives 2.0.0 to NuGet.org. |
| v2.0.0 ↗ | github | 2026-08-25 | Ecosystem Packages in this release | Package | Version | |---------|---------| | `EricksonLopez.DomainPrimitives.Abstractions` | `2.0.0` | | `EricksonLopez.DomainPrimitives` | `2.0.0` | | `EricksonLopez.DomainPrimitives.Generators` | `2.0.0` | | `EricksonLopez.DomainPrimitives.Analyzers` | `2.0.0` | | `EricksonLopez.DomainPrimitives.AspNetCore` | `2.0.0` | | `EricksonLopez.DomainPrimitives.AspN... |
| v1.0.0 ↗ | github | 2026-08-11 | Ecosystem Packages in this release | Package | Version | |---------|---------| | `EricksonLopez.DomainPrimitives` | `1.0.0` | | `EricksonLopez.DomainPrimitives.Generators` | `1.0.0` | | `EricksonLopez.DomainPrimitives.Abstractions` | `1.0.0` | | `EricksonLopez.DomainPrimitives.Analyzers` | `1.0.0` | | `EricksonLopez.DomainPrimitives.AspNetCore` | `1.0.0` | | `EricksonLopez.DomainPrimitives.AspN... |
| v1.0.0 ↗ | nuget | 2026-08-11 | Published EricksonLopez.DomainPrimitives 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 →
11 namespaces · 117 types · 298 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#
- Mark partial readonly record struct declarations explicitly so incremental source generators can emit BCL parser implementations.
- Check package-level AOT status: core primitives are Full AOT, while Newtonsoft.Json and SwaggerGen adapter packages are Partial or Incompatible.
- Version lag detected: NuGet.org latest published version is v3.0.0, while local repository HEAD is at v4.1.0.
20. Quality & Verification Evidence#
- Strong-Name Signing (`EricksonLopez.snk`)
- EricksonLopez.snk
- `ImplicitUsings=disable`
- disable
- XML Documentation Extraction
- Verified (11 namespaces, 117 types, 298 members)
- MSBuild AOT / Trim Attributes
- 6 Full / 1 Partial / 1 Incompatible / 6 N/A
- BenchmarkDotNet Artifacts
- 155 total (151 measured, 4 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).