Stunts.Extensions
1.0.0-beta.4
dotnet add package Stunts.Extensions --version 1.0.0-beta.4
NuGet\Install-Package Stunts.Extensions -Version 1.0.0-beta.4
<PackageReference Include="Stunts.Extensions" Version="1.0.0-beta.4" />
<PackageVersion Include="Stunts.Extensions" Version="1.0.0-beta.4" />
<PackageReference Include="Stunts.Extensions" />
paket add Stunts.Extensions --version 1.0.0-beta.4
#r "nuget: Stunts.Extensions, 1.0.0-beta.4"
#:package Stunts.Extensions@1.0.0-beta.4
#addin nuget:?package=Stunts.Extensions&version=1.0.0-beta.4&prerelease
#tool nuget:?package=Stunts.Extensions&version=1.0.0-beta.4&prerelease
Data annotations
The Stunts.Extensions package adds DataAnnotationsBehavior. It rejects a call when a built-in
System.ComponentModel.DataAnnotations attribute fails. The checks come from
NativeValidation:
a source generator turns each attribute into a direct call, so the behavior does not reflect and
stays valid for Native AOT.
var stunt = Stunt.For<IAccount>();
stunt.AddBehavior(new DataAnnotationsBehavior());
IAccount account = stunt.ToObject();
account.Email = "ada@example.com";
public interface IAccount
{
[Required]
[EmailAddress]
[Display(Name = "Email address")]
string Email { get; set; }
void Rename([Required, StringLength(8, MinimumLength = 2)] string name, [Range(1, 10)] int attempt);
}
Property attributes run on the setter. Method and constructor attributes run on the annotated
parameters. Getters are not checked. The first failure is a ValidationException, and the rest
of the pipeline does not run. Add this behavior last to place the check immediately before the
target. Behaviors added before it still see the rejection.
StuntGeneratorAttribute derives from ValidationAttribute, so a generic [StuntGenerator] method
registers the closed types named at its call sites. A factory that is not a stunt generator uses
[Validated] from Devlooped.DataAnnotations. A closed type with no factory call uses
[assembly: Validate<T>].
CompareAttribute reads the other property from the instance. On a stunt that call re-enters
the pipeline, so a SynchronizedBehavior wrapped outside this one throws on the re-entry.
CustomValidationAttribute is a direct call to the named static method. Any other
ValidationAttribute subclass warns as NVA001 and is not enforced.
Guards
The Stunts.Extensions package adds GuardBehavior. A predicate over the invocation returns an
exception to reject the call, or null to continue. The predicate does not call the rest of the
pipeline. Use it for validation, null checks, and authorization.
var stunt = Stunt.For<IOrders>();
stunt.AddBehavior(new GuardBehavior(call =>
call.MethodBase.Name == nameof(IOrders.Track) && call.Arguments.GetValue(0) is null
? new ArgumentNullException("sku")
: null));
IOrders orders = stunt.ToObject();
public interface IOrders
{
int Track(string sku);
}
A synchronous member throws that exception on the caller thread. A Task or ValueTask member
returns a faulted awaitable of the same type, and the rest of the pipeline does not run. Add this
behavior last to place the check immediately before the target. Behaviors added before it still
see the rejection. The constructor is an invocation too, so a behavior added before the stunt is
materialized sees that call.
Open Source Maintenance Fee
To ensure the long-term sustainability of this project, users of this package who generate revenue must pay an Open Source Maintenance Fee. While the source code is freely available under the terms of the License, this package and other aspects of the project require adherence to the Maintenance Fee.
To pay the Maintenance Fee, become a Sponsor at the proper OSMF tier. A single fee covers all of Devlooped packages.
Sponsors
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- NativeValidation (>= 0.1.1)
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 |
|---|---|---|
| 1.0.0-beta.4 | 46 | 11/17/2026 |