SuperStrong.Types
Strong types for .NET — define once, use everywhere!
What does this library do?
You write this:
csharp
[StrongType<Guid>]
public sealed partial class UserId;You get auto-generated:
- wrapping:
_value,From(...),TryFrom(...),AsPrimitive(),IStrongType<,> - equality:
==,!=,Equals(...),GetHashCode(),IEquatable<>,IEqualityOperators<,,> - comparison:
<,<=,>,>=,IComparable<>,IComparisonOperators<,,> - formatting:
ToString(...),IFormattable,ISpanFormattable,IUtf8SpanFormattable - parsing:
IParsable<>,ISpanParsable<>,IUtf8SpanParsable<> - conversion:
IConvertible,TypeConverter,JsonConverter
You can easily integrate it with:
- ASP.NET Core
- OpenAPI
- EF Core
- Hot Chocolate
- System.Text.Json
- Newtonsoft.Json
How to install?
Install the package from NuGet:
sh
dotnet add package SuperStrong.Types --version 1.0.0xml
<PackageReference Include="SuperStrong.Types" Version="1.0.0" />This library targets .NET 10, so your project should target .NET 10 or higher to be compatible with SuperStrong.Types.
Why use this library?
Fighting primitive obsession usually requires a lot of boilerplate.
SuperStrong.Types generates that boilerplate for you, so you can focus on modelling your domain instead of writing repetitive code.
What's next?
- Find out more in the tutorial
- Learn about strong type validation and customization
- Take a look at the available integrations
- Do 10 push-ups, 10 pull-ups, and 10 squats
Acknowledgements
SuperStrong.Types is inspired by two excellent libraries:
- StronglyTypedId by Andrew Lock
- Vogen by Steve Dunn
Thanks to both authors for the ideas and groundwork.
