StrongOf.AspNetCore
3.1.2
Requires NuGet 2.12 or higher.
dotnet add package StrongOf.AspNetCore --version 3.1.2
NuGet\Install-Package StrongOf.AspNetCore -Version 3.1.2
<PackageReference Include="StrongOf.AspNetCore" Version="3.1.2" />
<PackageVersion Include="StrongOf.AspNetCore" Version="3.1.2" />
<PackageReference Include="StrongOf.AspNetCore" />
paket add StrongOf.AspNetCore --version 3.1.2
#r "nuget: StrongOf.AspNetCore, 3.1.2"
#:package StrongOf.AspNetCore@3.1.2
#addin nuget:?package=StrongOf.AspNetCore&version=3.1.2
#tool nuget:?package=StrongOf.AspNetCore&version=3.1.2
StrongOf.AspNetCore
ASP.NET Core integration for StrongOf types. Includes MVC model binders, Minimal API validation, and OpenAPI schema transformation.
NativeAOT boundary
This extension package has no package-wide NativeAOT guarantee. The core StrongOf package is independently
AOT-compatible. ASP.NET Core MVC is not supported by NativeAOT; neither explicit model binders nor disabling
warnings changes that framework limitation.
Assembly-scanning registration is annotated with RequiresUnreferencedCode, and registration that constructs
closed generic binder types at runtime is annotated with RequiresDynamicCode. Prefer explicit binder mappings
for predictable registration in MVC applications. These mappings do not make MVC NativeAOT-compatible.
Minimal API applications have a different deployment model. Use the ASP.NET Core NativeAOT template, generated request delegates, and generated JSON metadata for all request/response types. The examples below show integration API usage, not a complete AOT application. User-defined strong types freshly generated in that application also need the explicit type-level JSON converter described in the JSON documentation. OpenAPI and other ASP.NET Core dependencies must be evaluated separately for the selected version.
See ASP.NET Core's compatibility table.
Installation
dotnet add package StrongOf.AspNetCore
MVC Model Binders (StrongOf.AspNetCore.Mvc)
Enables route values, query strings, and form fields to be automatically parsed into strong types.
Available Binders
| Binder | For |
|---|---|
StrongGuidBinder<T> |
StrongGuid<T> types |
StrongStringBinder<T> |
StrongString<T> types |
StrongInt32Binder<T> |
StrongInt32<T> types |
StrongInt64Binder<T> |
StrongInt64<T> types |
StrongDecimalBinder<T> |
StrongDecimal<T> types |
StrongDoubleBinder<T> |
StrongDouble<T> types |
StrongCharBinder<T> |
StrongChar<T> types |
StrongBooleanBinder<T> |
StrongBoolean<T> types |
StrongDateTimeBinder<T> |
StrongDateTime<T> types |
StrongDateTimeOffsetBinder<T> |
StrongDateTimeOffset<T> types |
StrongTimeSpanBinder<T> |
StrongTimeSpan<T> types |
Setup
Register the built-in StrongOf model binder provider in your ASP.NET Core startup. For most applications, passing the StrongOf model types directly is the simplest option:
using StrongOf.AspNetCore.Mvc;
// Program.cs
builder.Services.AddControllers(options =>
options.AddStrongOfModelBinderProvider(
typeof(UserId),
typeof(EmailAddress)));
If you want to register all StrongOf types from one or more assemblies, you can scan them automatically:
using StrongOf.AspNetCore.Mvc;
builder.Services.AddControllers(options =>
options.AddStrongOfModelBinderProviderFromAssemblies(typeof(UserId).Assembly));
The explicit Dictionary<Type, Type> overload remains available when you need full manual control.
Custom Binders
Extend StrongOfBinder to add custom parsing logic:
using StrongOf.AspNetCore.Mvc;
public sealed class MyUserIdBinder : StrongOfBinder
{
public override bool TryHandle(string value, out ModelBindingResult result)
{
if (StrongGuid<UserId>.TryParse(value, out UserId? id))
{
result = ModelBindingResult.Success(id);
return true;
}
result = ModelBindingResult.Failed();
return false;
}
}
Minimal APIs (StrongOf.AspNetCore.MinimalApis)
All strong types implement IParsable<TSelf> and work as route/query parameters in Minimal APIs out of the box.
Use the validation filter to automatically validate IValidatable parameters:
using StrongOf.AspNetCore.MinimalApis;
// Strong types work as route parameters out of the box
app.MapGet("/users/{id}", (UserId id) => Results.Ok(id));
// Register the endpoint filter for automatic validation of IValidatable types
app.MapPost("/users", (EmailAddress email) => Results.Ok(email))
.WithStrongOfValidation();
OpenAPI Schema Transformer (StrongOf.AspNetCore.OpenApi)
Requires .NET 9.0 or later
Maps strong types to their underlying primitive types in OpenAPI documentation,
so API schemas show string (uuid) instead of a complex object for UserId.
using StrongOf.AspNetCore.OpenApi;
builder.Services.AddOpenApi(options =>
{
options.AddSchemaTransformer<StrongOfSchemaTransformer>();
});
Type Mappings
| Strong Type | OpenAPI Type | OpenAPI Format |
|---|---|---|
StrongGuid<T> |
string |
uuid |
StrongString<T> |
string |
- |
StrongInt32<T> |
integer |
int32 |
StrongInt64<T> |
integer |
int64 |
StrongDecimal<T> |
number |
double |
StrongDouble<T> |
number |
double |
StrongBoolean<T> |
boolean |
- |
StrongChar<T> |
string |
- |
StrongDateTime<T> |
string |
date-time |
StrongDateTimeOffset<T> |
string |
date-time |
StrongTimeSpan<T> |
string |
duration |
Mapping is resolved via the IStrong* marker interfaces, so custom strong types are covered automatically without additional registration.
GitHub
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- Microsoft.AspNetCore.OpenApi (>= 10.0.10)
- Microsoft.OpenApi (>= 2.7.5)
- StrongOf (>= 3.1.2)
-
net11.0
- Microsoft.AspNetCore.OpenApi (>= 11.0.0-preview.3.26207.106)
- Microsoft.OpenApi (>= 3.6.0)
- StrongOf (>= 3.1.2)
-
net9.0
- Microsoft.AspNetCore.OpenApi (>= 9.0.18)
- Microsoft.OpenApi (>= 1.6.29)
- StrongOf (>= 3.1.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.1.2 | 60 | 10/4/2026 |
| 3.0.35 | 79 | 9/23/2026 |
| 3.0.31 | 1,136 | 6/17/2026 |
| 3.0.29 | 135 | 5/19/2026 |
| 2.1.37 | 279 | 4/21/2026 |
| 2.1.31 | 160 | 3/30/2026 |
| 2.1.26 | 148 | 3/7/2026 |
| 2.1.8 | 153 | 2/28/2026 |
| 2.0.2 | 400 | 2/20/2026 |
| 1.2.15 | 702 | 4/26/2025 |
| 1.2.8 | 292 | 4/9/2025 |
| 1.2.7 | 2,074 | 2/18/2025 |
| 1.2.7-ga639164e54 | 175 | 2/18/2025 |
| 1.2.4 | 1,131 | 11/28/2024 |
| 1.2.4-g0988d2c02d | 186 | 11/28/2024 |
| 1.2.2 | 850 | 11/15/2024 |
| 1.2.2-gbc3f3048e7 | 181 | 11/15/2024 |
| 1.1.4 | 231 | 11/12/2024 |
| 1.1.4-g6e854f6d6d | 193 | 11/12/2024 |
| 1.1.2 | 325 | 11/5/2024 |