Skip to content

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.0
xml
<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?

Acknowledgements

SuperStrong.Types is inspired by two excellent libraries:

Thanks to both authors for the ideas and groundwork.

Released under the MIT License.