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
  • EF Core
  • HotChocolate
  • OpenAPI
  • Dapper
  • MessagePack

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.