EricksonLopez.DomainPrimitives

dotnet-domain-primitives · Domain Modeling

On this page (20 sections)

1. Identity, Tier & Maturity Profile#

L0 Foundation PrimitivesStableMaintenance: ActiveAOT: PartialMIT LicenseConfidence: HIGH
Domainnet8.0net9.0net10.0netstandard2.0

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
Also published in this family:
EricksonLopez.DomainPrimitives.AbstractionsEricksonLopez.DomainPrimitives.OpenApiEricksonLopez.DomainPrimitives.AspNetCoreEricksonLopez.DomainPrimitives.DapperEricksonLopez.DomainPrimitives.TestingEricksonLopez.DomainPrimitives.EFCore

4. Verified Ecosystem Metrics#

v3.0.0
NuGet Published Version
v4.1.0
Repo HEAD Version
9,345
NuGet Downloads
14
Packable Packages
298
Public API Members
155
Benchmark Rows (RyuJIT)

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 IDStatusNuGet / LocalTFMsAOT StatusDownloadsDescription
EricksonLopez.DomainPrimitivesPrimaryPublishedv3.0.0 / v4.1.0net8.0, net9.0, net10.0AOT: Full525The 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.AbstractionsPublishedv3.0.0 / v4.1.0net8.0, net9.0, net10.0, netstandard2.0AOT: Full3,352Core 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.OpenApiPublishedv3.0.0 / v4.1.0net8.0, net9.0, net10.0AOT: Full472OpenAPI/Swashbuckle integration for EricksonLopez.DomainPrimitives. Generates precise schema specifications for domain primitives.
EricksonLopez.DomainPrimitives.AspNetCorePublishedv3.0.0 / v4.1.0net8.0, net9.0, net10.0AOT: Full457ASP.NET Core integration for EricksonLopez.DomainPrimitives. Automatically generates ModelBinders and Swagger/OpenAPI schemas for Domain Primitives.
EricksonLopez.DomainPrimitives.DapperPublishedv3.0.0 / v4.1.0net8.0, net9.0, net10.0AOT: Full457Dapper integration for EricksonLopez.DomainPrimitives. Automatically generates NativeAOT-ready SqlMapper.TypeHandler implementations for all domain primitives without reflection.
EricksonLopez.DomainPrimitives.TestingPublishedv3.0.0 / v4.1.0net8.0, net9.0, net10.0AOT: Partial447Testing library for EricksonLopez.DomainPrimitives. Provides Assertions, Builders, and Fakes for unit testing your domain primitives seamlessly with xUnit, NSubstitute and AwesomeAssertions.
EricksonLopez.DomainPrimitives.EFCorePublishedv3.0.0 / v4.1.0net8.0, net9.0, net10.0AOT: Full438EF Core integration for EricksonLopez.DomainPrimitives. Automatically generates NativeAOT-ready ValueConverters for all domain primitives without reflection.
EricksonLopez.DomainPrimitives.NewtonsoftJsonPublishedv3.0.0 / v4.1.0net8.0, net9.0, net10.0AOT: Incompatible299[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 / GeneratorPublishedv3.0.0 / v4.1.0netstandard2.0AOT: N/A (Analyzer/Legacy)654Source Generators for OpenApi integration with EricksonLopez.DomainPrimitives.
EricksonLopez.DomainPrimitives.GeneratorsAnalyzer / GeneratorPublishedv3.0.0 / v4.1.0netstandard2.0AOT: N/A (Analyzer/Legacy)468Incremental 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 / GeneratorPublishedv3.0.0 / v4.1.0netstandard2.0AOT: N/A (Analyzer/Legacy)458Roslyn 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 / GeneratorPublishedv3.0.0 / v4.1.0netstandard2.0AOT: N/A (Analyzer/Legacy)440Source Generators for ASP.NET Core integration with EricksonLopez.DomainPrimitives.
EricksonLopez.DomainPrimitives.Dapper.SourceGeneratorsAnalyzer / GeneratorPublishedv3.0.0 / v4.1.0netstandard2.0AOT: N/A (Analyzer/Legacy)440Source Generators for Dapper integration with EricksonLopez.DomainPrimitives.
EricksonLopez.DomainPrimitives.EFCore.SourceGeneratorsAnalyzer / GeneratorPublishedv3.0.0 / v4.1.0netstandard2.0AOT: N/A (Analyzer/Legacy)438Source 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#

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
EricksonLopez.DomainPrimitives Dependency Topology0 upstream library dependencies and 3 downstream dependent libraries verified in dependencies.json.
View accessible text summary and structure

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

DirectionLibraryTierRelationship Kinds
DownstreamEricksonLopez.SharedKernelL1Adapter, Compile-Time, NuGet Package
DownstreamEricksonLopez.ValueObjectsL1Compile-Time, NuGet Package
DownstreamEricksonLopez.MapperL2Compile-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_primitives

10. Target Frameworks & Native AOT / Trimming Matrix#

MSBuild `.csproj` inspection across 14 packages: 6 Full, 1 Partial, 1 Incompatible, 6 NotApplicable (analyzers/generators).

Package IDIsAotCompatibleEnableTrimAnalyzerVerified AOT StatusTarget Frameworks
EricksonLopez.DomainPrimitivestruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.DomainPrimitives.AbstractionstruetrueFullnet8.0, net9.0, net10.0, netstandard2.0
EricksonLopez.DomainPrimitives.OpenApitruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.DomainPrimitives.AspNetCoretruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.DomainPrimitives.DappertruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.DomainPrimitives.TestingtruefalsePartialnet8.0, net9.0, net10.0
EricksonLopez.DomainPrimitives.EFCoretruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.DomainPrimitives.NewtonsoftJsonfalsefalseIncompatiblenet8.0, net9.0, net10.0
EricksonLopez.DomainPrimitives.OpenApi.SourceGeneratorsnullnullNotApplicablenetstandard2.0
EricksonLopez.DomainPrimitives.GeneratorsnullnullNotApplicablenetstandard2.0
EricksonLopez.DomainPrimitives.AnalyzersnullnullNotApplicablenetstandard2.0
EricksonLopez.DomainPrimitives.AspNetCore.SourceGeneratorsnullnullNotApplicablenetstandard2.0
EricksonLopez.DomainPrimitives.Dapper.SourceGeneratorsnullnullNotApplicablenetstandard2.0
EricksonLopez.DomainPrimitives.EFCore.SourceGeneratorsnullnullNotApplicablenetstandard2.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

Verified External NuGet Dependencies (7)

AwesomeAssertionsDapperMicrosoft.EntityFrameworkCoreMicrosoft.Extensions.DependencyInjectionNewtonsoft.JsonSwashbuckle.AspNetCore.SwaggerGenVerify.Xunit

13. Configuration & DI Registration Summary#

Verified DI & Configuration Entry Points

  • DomainPrimitivesMvcBuilderExtensions.AddDomainPrimitivesModelBinding

    Adds domain primitive model binding to the service collection.

  • NewtonsoftJsonExtensions.AddDomainPrimitives

    Adds 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).

Total rows: 155 · Measured: 151 · NA / Error: 4 · Suites: 3

Observed runtimes: .NET 10.0.12 X64 RyuJIT x86-64-v3 · .NET 8.0.30 X64 RyuJIT x86-64-v4 · .NET 8.0.31 X64 RyuJIT x86-64-v3 · .NET 9.0.20 X64 RyuJIT x86-64-v3

Observed CPUs: AMD EPYC 7763 2.45GHz, 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
ComparativeBenchmarksValueObject_Create.NET 9.0.20 X64 RyuJIT x86-64-v30.0010measured
DomainPrimitiveBenchmarksRawGuid.NET 9.0.20 X64 RyuJIT x86-64-v30.1140measured
ComparativeBenchmarksStronglyTypedId_Create.NET 10.0.12 X64 RyuJIT x86-64-v30.1340measured
ComparativeBenchmarksMeziantou_Create.NET 9.0.20 X64 RyuJIT x86-64-v30.1640measured
ComparativeBenchmarksMeziantou_Create.NET 8.0.31 X64 RyuJIT x86-64-v30.1670measured
ComparativeBenchmarksTinyTypes_Create.NET 8.0.31 X64 RyuJIT x86-64-v30.1710measured
ComparativeBenchmarksStronglyTypedId_Create.NET 9.0.20 X64 RyuJIT x86-64-v30.1730measured
ComparativeBenchmarksStronglyTypedId_Create.NET 8.0.31 X64 RyuJIT x86-64-v30.1920measured
ComparativeBenchmarksRawGuid_Create.NET 9.0.20 X64 RyuJIT x86-64-v30.2160measured
ComparativeBenchmarksTinyTypes_Create.NET 10.0.12 X64 RyuJIT x86-64-v30.2470measured
ComparativeBenchmarksRawGuid_Create.NET 8.0.31 X64 RyuJIT x86-64-v30.2530measured
ComparativeBenchmarksMeziantou_Create.NET 10.0.12 X64 RyuJIT x86-64-v30.3090measured
DomainPrimitiveBenchmarksRawGuid.NET 10.0.12 X64 RyuJIT x86-64-v30.3140measured
DomainPrimitiveBenchmarksRawGuid.NET 8.0.31 X64 RyuJIT x86-64-v30.3240measured
ComparativeBenchmarksValueObject_Create.NET 10.0.12 X64 RyuJIT x86-64-v30.3250measured
ComparativeBenchmarksValueObject_Create.NET 8.0.31 X64 RyuJIT x86-64-v30.3310measured
ComparativeBenchmarksRawGuid_Create.NET 10.0.12 X64 RyuJIT x86-64-v30.3380measured
ComparativeBenchmarksDapper_TypeHandler_SetValue.NET 10.0.12 X64 RyuJIT x86-64-v30.3450measured
ComparativeBenchmarksVogen_Create.NET 10.0.12 X64 RyuJIT x86-64-v30.3840measured
ComparativeBenchmarksVogen_Create.NET 9.0.20 X64 RyuJIT x86-64-v30.5470measured
ComparativeBenchmarksDomainPrimitives_EqualityCheck.NET 8.0.31 X64 RyuJIT x86-64-v30.7980measured
DomainPrimitiveBenchmarksPrimitiveGuid.NET 9.0.20 X64 RyuJIT x86-64-v30.8520measured
ComparativeBenchmarksDomainPrimitives_Create.NET 10.0.12 X64 RyuJIT x86-64-v30.870measured
ComparativeBenchmarksEFCore_ValueConverter_ConvertFromProvider.NET 10.0.12 X64 RyuJIT x86-64-v30.8790measured
DomainPrimitiveBenchmarksPrimitiveGuid.NET 8.0.31 X64 RyuJIT x86-64-v30.8820measured

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.

VersionSourcePublished DateSummary
v3.0.0 ↗nuget2026-09-20Published EricksonLopez.DomainPrimitives 3.0.0 to NuGet.org.
v3.0.0 ↗github2026-09-20Ecosystem 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 ↗nuget2026-08-25Published EricksonLopez.DomainPrimitives 2.0.0 to NuGet.org.
v2.0.0 ↗github2026-08-25Ecosystem 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 ↗github2026-08-11Ecosystem 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 ↗nuget2026-08-11Published EricksonLopez.DomainPrimitives 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#

  • 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).

Search EricksonLopez.* Ecosystem

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