EricksonLopez.DomainPrimitives Overview
EricksonLopez.DomainPrimitives (3.0.0 on NuGet, L0) eliminates Primitive Obsession at compile time using Roslyn incremental source generators on readonly partial record struct types (ADR-011).
- Compile-time factory, parser, and formatter generation: Emits
Create,TryCreate(..., out PrimitiveError),Parse,TryParse(IParsable<T>,ISpanParsable<T>,IUtf8SpanParsable<T>),ISpanFormattable,IUtf8SpanFormattable, and explicit conversions. - Zero-allocation numeric & ID hot paths: StrongIds, SmartEnums, and numeric primitives reside on the stack (
0 Bheap allocation). String primitives apply NFC Unicode normalization where configured. - Live IDE enforcement:
DP0001–DP0018(Analyzers) andDP1001–DP1005(Generators) catch invalid primitive declarations and constructor bypasses during compilation. - Verified attribute surface: Uses
[StrongId<T>],[StringPrimitive],[NumericPrimitive<T>],[DatePrimitive],[SmartEnum<T>],[ValueObject], plus 39+ semantic shortcuts ([Email],[Phone],[IBAN],[Money], etc.).
Package Roster & Native AOT Status (14 / 14 Published)
Section titled “Package Roster & Native AOT Status (14 / 14 Published)”| Package | AOT Status | Role |
|---|---|---|
EricksonLopez.DomainPrimitives |
Full |
Core attributes, PrimitiveBuilder, AmortizationScheduleCalculator, diagnostics |
EricksonLopez.DomainPrimitives.Abstractions |
Full (net8.0+) |
Contracts (IDomainPrimitive<TSelf, TValue>, IStrongId<TSelf, TValue>, PrimitiveError) |
EricksonLopez.DomainPrimitives.AspNetCore / .SourceGenerators |
Full / NotApplicable |
Model binding, DomainPrimitiveValidationAttribute<TPrimitive, TValue> |
EricksonLopez.DomainPrimitives.Dapper / .SourceGenerators |
Full / NotApplicable |
DapperDomainPrimitivesRegistration.RegisterAll() |
EricksonLopez.DomainPrimitives.EFCore / .SourceGenerators |
Full / NotApplicable |
configurationBuilder.ConfigureDomainPrimitives() |
EricksonLopez.DomainPrimitives.OpenApi / .SourceGenerators |
Full / NotApplicable |
options.SchemaFilter<DomainPrimitivesSchemaFilter>() Swagger schema registration |
EricksonLopez.DomainPrimitives.Testing |
Partial |
DomainPrimitiveFakeFactory, DomainPrimitiveScenarios, Verify extensions (EnableTrimAnalyzer=false) |
EricksonLopez.DomainPrimitives.NewtonsoftJson |
Incompatible |
Legacy Newtonsoft.Json adapter (IsAotCompatible=false, EnableTrimAnalyzer=false) |
EricksonLopez.DomainPrimitives.Analyzers / .Generators |
NotApplicable |
Roslyn analyzers (DP0001–DP0018) and generators (DP1001–DP1005) |
Measured directly from BenchmarkDotNet.Artifacts (151 measured rows on .NET 8/.NET 9/.NET 10 X64 RyuJIT; 4 na_error rows in StructLayoutBenchmark excluded):
ComparativeBenchmarks.Dapper_TypeHandler_Parse: 0.8982–0.9405 ns / 0 BDomainPrimitiveBenchmarks.PrimitiveEmail_Create: 110.70 ns / 0 B