Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Latest commit

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

StrongIDs

StrongIDs is a NuGet package designed to simplify strongly typed IDs in C# projects by reducing boilerplate code and enhancing codebase clarity.

Strongly typed IDs provided by StrongIDs wrap Guids, offering a clean and efficient way to handle unique identifiers.

Installation

Install package via NuGet:

dotnet add package StrongIDs

Usage

Strongly typed IDs can have the following access modifiers:

  • protected internal
  • protected
  • internal
  • public

Define a strongly typed ID using StrongIDs. Ensure it is readonly, partial, and a record struct. For example:

publicreadonlypartialrecordstructUserId:IStrongId<UserId>;

This generates the following code, implementing the IEntityId interface:

publicpartialrecordstructUserId:IEntityId<UserId>{publicGuidValue{get;}publicboolHasValue=>Value!=Guid.Empty;privateUserId(Guidvalue)=>Value=value;publicstaticUserIdEmpty=>newUserId(Guid.Empty);publicstaticUserIdNew()=>newUserId(Guid.NewGuid());publicstaticUserIdParse(string?value)=>Guid.TryParse(value,outGuidid)?newUserId(id):Empty;}

The IEntityId interface requires the above generated methods and properties to be implemented.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages