FastFsm.Net 0.9.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package FastFsm.Net --version 0.9.0
                    
NuGet\Install-Package FastFsm.Net -Version 0.9.0
                    
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="FastFsm.Net" Version="0.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FastFsm.Net" Version="0.9.0" />
                    
Directory.Packages.props
<PackageReference Include="FastFsm.Net" />
                    
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 FastFsm.Net --version 0.9.0
                    
#r "nuget: FastFsm.Net, 0.9.0"
                    
#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 FastFsm.Net@0.9.0
                    
#: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=FastFsm.Net&version=0.9.0
                    
Install as a Cake Addin
#tool nuget:?package=FastFsm.Net&version=0.9.0
                    
Install as a Cake Tool

FastFsm

Source-generated finite and hierarchical state machines for .NET 10.

FastFsm generates switch-based state-machine code at build time. Machines can be configured with either the Fluent API or the Attribute API. The generator validates transitions, guards, callbacks, and hierarchy during compilation.

Repository package version: 0.9.0 (defined in Directory.Build.props). See CHANGELOG.md.

Install

dotnet add package FastFsm.Net
# optional
dotnet add package FastFsm.Net.Logging
dotnet add package FastFsm.Net.DependencyInjection

Requires .NET SDK 10.0 (see global.json).

Configuration APIs

Both APIs use the same generator and runtime.

Fluent API

using Abstractions.Fluent;
using Abstractions.Attributes;

public enum DoorState { Closed, Open }
public enum DoorTrigger { Open, Close }

[StateMachine(typeof(DoorState), typeof(DoorTrigger))]
public partial class DoorController
{
    private void Configure() => FSM
        .State(DoorState.Closed)
            .On(DoorTrigger.Open).GoTo(DoorState.Open)
        .State(DoorState.Open)
            .On(DoorTrigger.Close).GoTo(DoorState.Closed);
}

See docs/fluent-api.md.

Attribute API

using Abstractions.Attributes;

public enum DoorState { Closed, Open }
public enum DoorTrigger { Open, Close }

[StateMachine(typeof(DoorState), typeof(DoorTrigger))]
public partial class DoorController
{
    [Transition(DoorState.Closed, DoorTrigger.Open, DoorState.Open)]
    [Transition(DoorState.Open, DoorTrigger.Close, DoorState.Closed)]
    private void ConfigureTransitions() { }
}

See docs/attribute-api.md.

For either form, create the generated machine with an initial state, call Start(), then use Fire() or TryFire():

var door = new DoorController(DoorState.Closed);
door.Start();
door.Fire(DoorTrigger.Open);              // throws when no valid transition exists
bool ok = door.TryFire(DoorTrigger.Close); // returns false when no valid transition exists

Features

  • Compile-time validation of state-machine definitions
  • Synchronous and asynchronous machines (ValueTask on asynchronous paths)
  • Hierarchical states, shallow and deep history, internal transitions, and transition priority
  • Typed payloads per trigger
  • IStateMachineExtension transition hooks
  • Optional logging through FastFsm.Net.Logging
  • Optional dependency-injection integration through FastFsm.Net.DependencyInjection
  • Generated code paths compatible with trimming and Native AOT

Documentation

Topic Guide
Setup and first machine docs/getting-started.md
Fluent API docs/fluent-api.md
Attribute API docs/attribute-api.md
Hierarchical machines docs/hsm.md
Async docs/async.md
Payloads docs/payloads.md
Extensions docs/extensions.md
Logging docs/logging.md
Dependency injection docs/dependency-injection.md
Diagnostics (FSM0100–FSM3083) docs/diagnostics.md
Architecture docs/architecture.md
Benchmarks docs/benchmarks.md
Changelog CHANGELOG.md
Roadmap ROADMAP.md

Packages

Package Purpose
FastFsm.Net Runtime and source generator
FastFsm.Net.Logging ILogger integration for generated machines
FastFsm.Net.DependencyInjection Microsoft.Extensions.DependencyInjection registration helpers

Repository layout

  • FastFsm/ — runtime packaged as FastFsm.Net
  • Abstractions/ — attributes and Fluent API definitions
  • Generator/ — Roslyn source generator
  • Generator.Rules/ — diagnostic rule definitions (RuleIdentifiers, DefinedRules)
  • Machines.Tests/ — shared machine definitions used across test projects

Contributing

Build and test from a clean tree. With UsePackages=false, test projects use project references rather than a pre-built 0.9.0 package.

dotnet test FastFsm.slnx -c Release

That runs FastFsm.Tests, FastFsm.Async.Tests, FastFsm.Logging.Tests, FastFsm.DependencyInjection.Tests, FastFsm.Instance.Tests, and Generator.Tests. Machines.Tests is a shared machine library, not a test runner.

Pack the three NuGet packages and compile clean consumer consoles against ./nuget:

# Windows
./scripts/pack-and-smoke.ps1
# Linux / macOS
bash ./scripts/pack-and-smoke.sh

CI for pull requests runs on GitHub-hosted runners (.github/workflows/ci.yml). Self-hosted Windows/Linux/macOS jobs run only on push to main and workflow_dispatch (.github/workflows/ci-self-hosted.yml).

See docs/architecture.md for the generator layout.

License

MIT — see LICENSE.

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.
  • net10.0

    • No dependencies.

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
0.9.1 93 8/17/2026
0.9.0 106 8/17/2026
0.6.9.13 212 8/22/2025
0.6.9.4 203 8/21/2025
0.6.9.3 210 8/20/2025
0.6.9.2 211 8/20/2025
0.6.9-pre-release 219 8/19/2025

.NET 10. Extension generation is opt-in. Warning-free generated code for typical machines. See CHANGELOG.md.