Stunts.Extensions 1.0.0-beta.4

This is a prerelease version of Stunts.Extensions.
dotnet add package Stunts.Extensions --version 1.0.0-beta.4
                    
NuGet\Install-Package Stunts.Extensions -Version 1.0.0-beta.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Stunts.Extensions" Version="1.0.0-beta.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Stunts.Extensions" Version="1.0.0-beta.4" />
                    
Directory.Packages.props
<PackageReference Include="Stunts.Extensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Stunts.Extensions --version 1.0.0-beta.4
                    
#r "nuget: Stunts.Extensions, 1.0.0-beta.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Stunts.Extensions@1.0.0-beta.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Stunts.Extensions&version=1.0.0-beta.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Stunts.Extensions&version=1.0.0-beta.4&prerelease
                    
Install as a Cake Tool

EULA OSS GitHub

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

Clarius Org MFB Technologies, Inc. SandRock DRIVE.NET, Inc. Keith Pickford Thomas Bolon Jacob Foshee alternate text is missing from this package README image Eric Johnson Jonathan Ken Bonny Simon Cropp agileworks-eu Zheyu Shen Vezel ChilliCream 4OTC domischell Adrian Alonso torutek Ryan McCaffery Seika Logiciel Andrew Grant eska-gmbh Geodata AS Röbbek Capital Schüco

Sponsor this project

Learn more about GitHub Sponsors

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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