FastFsm.Sharp 0.9.1

dotnet add package FastFsm.Sharp --version 0.9.1
                    
NuGet\Install-Package FastFsm.Sharp -Version 0.9.1
                    
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.Sharp" Version="0.9.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FastFsm.Sharp" Version="0.9.1" />
                    
Directory.Packages.props
<PackageReference Include="FastFsm.Sharp" />
                    
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.Sharp --version 0.9.1
                    
#r "nuget: FastFsm.Sharp, 0.9.1"
                    
#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.Sharp@0.9.1
                    
#: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.Sharp&version=0.9.1
                    
Install as a Cake Addin
#tool nuget:?package=FastFsm.Sharp&version=0.9.1
                    
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.1 (defined in Directory.Build.props). See CHANGELOG.md. 0.9.1 is on NuGet.org as FastFsm.Sharp*, with legacy FastFsm.Net* metapackages forwarding to the same bits.

Install

dotnet add package FastFsm.Sharp
# optional
dotnet add package FastFsm.Sharp.Logging
dotnet add package FastFsm.Sharp.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.Sharp.Logging
  • Optional dependency-injection integration through FastFsm.Sharp.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.Sharp Runtime and source generator
FastFsm.Sharp.Logging ILogger integration for generated machines
FastFsm.Sharp.DependencyInjection Microsoft.Extensions.DependencyInjection registration helpers

Migrating from FastFsm.Net 0.6.9.x: new projects use FastFsm.Sharp*. Existing FastFsm.Net* references can stay — 0.9.0 ships legacy metapackages that forward to FastFsm.Sharp* (see CHANGELOG.md). Your machine code (Abstractions.*, FastFsm.*) stays the same. Details: docs/architecture.md.

Repository layout

  • src/Fsm/Fsm.Core/ — runtime packaged as FastFsm.Sharp
  • src/Abstractions/ — attributes and Fluent API definitions
  • src/Generator/ — Roslyn source generator (Generator.Core, Generator.Model, Generator.Rules, …)
  • src/Generator/Generator.Rules/ — diagnostic rule definitions (RuleIdentifiers, DefinedRules)
  • src/Fsm/Fsm.Tests/Tests.Machines/ — shared machine definitions used by Tests.Fsm and Tests.Logging
  • src/Fsm/Fsm.Tests/Tests.*/ — FSM test runners (Tests.Fsm, Tests.Async, Tests.Logging, …)
  • src/Generator/Generator.Tests/Tests.SourceGenerators/ — generator rule and emission tests

Contributing

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

dotnet test FastFsm.slnx -c Release

That runs Tests.Fsm, Tests.Async, Tests.Logging, Tests.DependencyInjection, Tests.Instance, and Tests.SourceGenerators. Tests.Machines 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 (3)

Showing the top 3 NuGet packages that depend on FastFsm.Sharp:

Package Downloads
FastFsm.Net

Legacy package ID. Depends on FastFsm.Sharp, which contains the runtime, Abstractions, and Roslyn analyzers. New projects should reference FastFsm.Sharp directly.

FastFsm.Sharp.DependencyInjection

Dependency injection support for FastFsm.Sharp state machines. Enables logging generation.

FastFsm.Sharp.Logging

Logging support for FastFsm.Sharp state machines (ILogger).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.1 0 8/17/2026
0.9.0 40 8/17/2026

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