StrongOf 2.0.2

Requires NuGet 2.12 or higher.

dotnet add package StrongOf --version 2.0.2
                    
NuGet\Install-Package StrongOf -Version 2.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="StrongOf" Version="2.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StrongOf" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="StrongOf" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add StrongOf --version 2.0.2
                    
#r "nuget: StrongOf, 2.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package StrongOf@2.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=StrongOf&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=StrongOf&version=2.0.2
                    
Install as a Cake Tool

StrongOf

StrongOf helps to implement primitives as a strong type that represents a domain object (e.g. UserId, EmailAddress, etc.). It is a simple class that wraps a value and provides a few helper methods, preventing parameter-order bugs at compile time.

Available Base Types

Base Class Wraps
StrongString<T> string
StrongGuid<T> Guid
StrongInt32<T> int
StrongInt64<T> long
StrongDecimal<T> decimal
StrongChar<T> char
StrongDateTime<T> DateTime
StrongDateTimeOffset<T> DateTimeOffset

Quick Start

// Define your types using the CRTP pattern
public sealed class UserId(Guid value) : StrongGuid<UserId>(value) { }
public sealed class Email(string value) : StrongString<Email>(value) { }

// Instantiation
UserId userId = new(Guid.NewGuid());  // preferred — fastest
UserId userId2 = UserId.From(Guid.NewGuid()); // via cached factory delegate

// Accessing the value
Guid rawId = userId.Value;

// Nullable factory
UserId? optional = UserId.From(nullableGuid);

// TryParse
bool parsed = UserId.TryParse("550e8400-...", out UserId? id);

// Strongly-typed comparison and sorting
bool equal = userId == userId2;
ids.Sort(); // works via IComparable<T>

Generic TypeConverters

The StrongOf package ships generic TypeConverter implementations for each base type, usable directly in domain types via the [TypeConverter] attribute:

[TypeConverter(typeof(StrongGuidTypeConverter<UserId>))]
public sealed class UserId(Guid value) : StrongGuid<UserId>(value) { }

Available converters: StrongStringTypeConverter<T>, StrongGuidTypeConverter<T>, StrongInt32TypeConverter<T>, StrongInt64TypeConverter<T>, StrongDecimalTypeConverter<T>, StrongDateTimeTypeConverter<T>.

Interfaces

  • IStrongOf — base marker interface
  • IStrongString, IStrongGuid, IStrongInt32, etc. — for generic constraints
  • IValidatable — for types that validate their own format via IsValidFormat()

GitHub

See https://github.com/BenjaminAbt/StrongOf

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net11.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on StrongOf:

Package Downloads
StrongOf.Json

StrongOf helps to implement primitives as a strong type that represents a domain object (e.g. UserId, EmailAddress, etc.). It is a simple class that wraps a value and provides a few helper methods to make it easier to work with. In contrast to other approaches, StrongOf is above all simple and performant - and not over-engineered.

StrongOf.AspNetCore

StrongOf helps to implement primitives as a strong type that represents a domain object (e.g. UserId, EmailAddress, etc.). It is a simple class that wraps a value and provides a few helper methods to make it easier to work with. In contrast to other approaches, StrongOf is above all simple and performant - and not over-engineered.

StrongOf.FluentValidation

StrongOf helps to implement primitives as a strong type that represents a domain object (e.g. UserId, EmailAddress, etc.). It is a simple class that wraps a value and provides a few helper methods to make it easier to work with. In contrast to other approaches, StrongOf is above all simple and performant - and not over-engineered.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on StrongOf:

Repository Stars
gitextensions/gitextensions
Git Extensions is a standalone UI tool for managing git repositories. It also integrates with Windows Explorer and Microsoft Visual Studio (2015/2017/2019).
Version Downloads Last Updated
2.0.2 116 2/20/2026
1.2.15 2,880 4/26/2025
1.2.8 468 4/9/2025
1.2.7 2,575 2/18/2025
1.2.7-ga639164e54 196 2/18/2025
1.2.4 5,473 11/28/2024
1.2.4-g0988d2c02d 223 11/28/2024
1.2.2 839 11/15/2024
1.2.2-gbc3f3048e7 202 11/15/2024
1.1.4 577 11/12/2024
1.1.4-g6e854f6d6d 202 11/12/2024
1.1.2 308 11/5/2024
1.1.2-g0a1a51912f 197 11/5/2024
0.1.71 342 11/3/2024
0.1.71-g40ec49b665 220 11/3/2024
0.1.65 5,290 6/2/2024
0.1.65-g31f777a546 232 6/2/2024
0.1.63 262 6/1/2024
0.1.63-g3ca390c476 225 6/1/2024
0.1.61 570 4/29/2024
Loading failed