What problem does it solve?
StructId helps you avoid “stringly-typed” and loosely-typed identifier bugs by making every ID a distinct, strongly-typed value (as a readonly partial record struct), while keeping runtime dependencies at zero through source generation.
Core Features & Use Cases
- Strongly-typed identifiers: Define
IStructId (string-backed) and IStructId<TValue> (struct-backed) IDs using readonly partial record struct so your compiler prevents mixing IDs accidentally.
- Factories via INewable: Use
INewable<TSelf> / INewable<TSelf, TValue> for consistent New(...) creation patterns (including parameterless New() for Guid and Ulid-backed IDs).
- Integration that “just activates”: Enable EF Core converters, Dapper type handlers, and System.Text.Json / Newtonsoft.Json converters automatically when you reference the corresponding packages.
- Template-based extension: Extend multiple (or filtered) ID types using
[TStructId] templates and specialized per-value-type handlers using [TValue].
Quick Start
Ask the AI: “Given I want a typed UserId(Guid) and a typed ProductId(int), show the two readonly partial record struct declarations using StructId and explain which New(...) overloads to call and how to enable EF Core and Dapper support.”