Stateless 5.16.0-dev-9828500365

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

Stateless

Create state machines and lightweight state machine-based workflows directly in .NET code:

var phoneCall = new StateMachine<State, Trigger>(State.OffHook);

phoneCall.Configure(State.OffHook)
    .Permit(Trigger.CallDialled, State.Ringing);

phoneCall.Configure(State.Connected)
    .OnEntry(t => StartCallTimer())
    .OnExit(t => StopCallTimer())
    .InternalTransition(Trigger.MuteMicrophone, t => OnMute())
    .InternalTransition(Trigger.UnmuteMicrophone, t => OnUnmute())
    .InternalTransition<int>(_setVolumeTrigger, (volume, t) => OnSetVolume(volume))
    .Permit(Trigger.LeftMessage, State.OffHook)
    .Permit(Trigger.PlacedOnHold, State.OnHold);

// ...

phoneCall.Fire(Trigger.CallDialled);
Assert.AreEqual(State.Ringing, phoneCall.State);

This project, as well as the example above, was inspired by Simple State Machine (Archived).

Features

Most standard state machine constructs are supported:

  • Generic support for states and triggers of any .NET type (numbers, strings, enums, etc.)
  • Hierarchical states
  • Entry/exit actions for states
  • Guard clauses to support conditional transitions
  • Introspection

Some useful extensions are also provided:

  • Ability to store state externally (for example, in a property tracked by an ORM)
  • Parameterised triggers
  • Reentrant states
  • Export to DOT graph

Documentation

For guidance on how to use Stateles, the project README file contains documentation and code examples. The source repository also includes a few example projects.

Contributing

We welcome contributions to this project. Check CONTRIBUTING.md for more info.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (57)

Showing the top 5 NuGet packages that depend on Stateless:

Package Downloads
LittleForker

A utility to assist with spawing child processes, monitor their lifecycle and co-operative shutdown.

DiegoRangel.DotNet.Framework.CQRS.Domain.Core

A common library for implementing CQRS based Domain layer.

Hyperledger.Aries

.NET Core tools for building agent services

RedoSocial.Platform.ViewModels.Rx

Package Description

RawRabbit.Operations.StateMachine

Integrate RawRabbit with the Stateless StateMachine.

GitHub repositories (13)

Showing the top 13 popular GitHub repositories that depend on Stateless:

Repository Stars
microsoft/ailab
Experience, Learn and Code the latest breakthrough innovations with Microsoft AI
github/VisualStudio
GitHub Extension for Visual Studio
sipsorcery-org/sipsorcery
A WebRTC, SIP and VoIP library for C# and .NET. Designed for real-time communications apps.
Azure/iotedge
The IoT Edge OSS project
dotnetGame/MineCase
Minecraft server based on Orleans
pardahlman/RawRabbit
A modern .NET framework for communication over RabbitMq
fagenorn/handcrafted-persona-engine
An AI-powered interactive avatar engine using Live2D, LLM, ASR, TTS, and RVC. Ideal for VTubing, streaming, and virtual assistant applications.
JasonBock/Rocks
A mocking library based on the Compiler APIs (Roslyn + Mocks)
CrossGeeks/xUber
Uber Clone using Xamarin Forms
DynamicTranslator/DynamicTranslator
Instant translation application for windows in .NET :circus_tent:
damianh/LittleForker
A .NET utility library to spawn, supervise and (optionally) cleanly shut down child processes.
Kaioru/Edelstein
A v.95.1 Mushroom game server emulator written in C# .NET
mrsalmon1976/Stateless.WorkflowEngine
Basic .NET workflow engine based on the awesome stateless State Machine.
Version Downloads Last updated
5.17.0 418,151 12/30/2024
5.17.0-dev-12573353197 119 1/1/2025
5.17.0-dev-12536414383 94 12/29/2024
5.16.0 1,488,278 5/24/2024
5.16.0-dev-9828500365 148 7/7/2024
5.16.0-dev-9514287026 121 6/14/2024
5.16.0-dev-9221217254 128 5/24/2024
5.16.0-dev-12536374438 86 12/29/2024
5.16.0-dev-12479904394 96 12/24/2024
5.16.0-dev-12470918423 101 12/23/2024
5.16.0-dev-12470449205 94 12/23/2024
5.16.0-dev-10048603300 129 7/22/2024
5.15.0 1,288,606 12/29/2023
5.15.0-dev-9171714096 133 5/21/2024
5.15.0-dev-9058520056 133 5/13/2024
5.15.0-dev-8822304149 134 4/24/2024
5.15.0-dev-8790594175 133 4/22/2024
5.15.0-dev-8759383160 126 4/19/2024
5.15.0-dev-7356157229 441 12/29/2023
5.14.0 396,540 11/14/2023
5.14.0-dev-7355700004 434 12/29/2023
5.14.0-dev-7309801955 412 12/23/2023
5.14.0-dev-7232734414 457 12/16/2023
5.14.0-dev-7232709282 480 12/16/2023
5.14.0-dev-7164312319 496 12/11/2023
5.14.0-dev-7078872236 502 12/3/2023
5.14.0-dev-7078811950 485 12/3/2023
5.14.0-dev-6860395514 493 11/14/2023
5.14.0-dev-6851669594 471 11/13/2023
5.14.0-dev-6851630770 469 11/13/2023
5.14.0-dev-6823242034 968 11/10/2023
5.14.0-dev-6813247520 498 11/9/2023
5.14.0-dev-6811706736 446 11/9/2023
5.14.0-dev-6801352798 475 11/8/2023
5.13.0 2,269,448 12/29/2022
5.13.0-dev-6799430915 475 11/8/2023
5.13.0-dev-6746401636 472 11/7/2023
5.13.0-dev-5455458583 783 7/4/2023
5.13.0-dev-5455401408 660 7/4/2023
5.13.0-dev-5235510771 643 6/11/2023
5.13.0-dev-5157129238 697 6/2/2023
5.13.0-dev-4941000713 774 5/10/2023
5.13.0-dev-4940972813 773 5/10/2023
5.13.0-dev-4838097297 679 4/29/2023
5.13.0-dev-4838091545 696 4/29/2023
5.13.0-dev-4838052982 684 4/29/2023
5.13.0-dev-4832488606 667 4/28/2023
5.13.0-dev-4716514070 687 4/17/2023
5.13.0-dev-4701624597 702 4/14/2023
5.13.0-dev-4701061956 679 4/14/2023
5.13.0-dev-4027208421 700 1/27/2023
5.13.0-dev-4027203589 729 1/27/2023
5.13.0-dev-4027201259 732 1/27/2023
5.13.0-dev-3800477155 696 12/29/2022
5.12.0 796,891 10/17/2022
5.12.0-dev-3553426836 713 11/26/2022
5.12.0-dev-3498786305 714 11/18/2022
5.12.0-dev-3267018252 722 10/17/2022
5.11.0 4,257,426 4/28/2021
5.11.0-dev-3264102134 696 10/17/2022
5.11.0-dev-3191463566 674 10/17/2022
5.10.1 473,928 2/17/2021
5.10.1-dev-791423646 886 4/28/2021
5.10.1-dev-787896296 873 4/27/2021
5.10.1-dev-787889564 895 4/27/2021
5.10.1-dev-574334224 896 2/17/2021
5.10.0 5,014 2/14/2021
5.10.0-dev-560201439 854 2/12/2021
5.10.0-dev-560186344 900 2/12/2021
5.10.0-dev-542672901 1,021 2/6/2021
5.10.0-dev-542661127 932 2/6/2021
5.2.0 5,650 2/15/2021
5.2.0-dev-568743626 927 2/15/2021
5.1.9-dev-00610 920 2/6/2021
5.1.9-dev-00600 917 1/31/2021
5.1.8 586,609 1/13/2021
5.1.8-dev-00558 906 1/16/2021
5.1.8-dev-00553 946 1/13/2021
5.1.7 26,836 1/10/2021
5.1.7-dev-00548 971 1/10/2021
5.1.6 3,124 1/10/2021
5.1.6-dev-00547 965 1/10/2021
5.1.6-dev-00544 941 1/10/2021
5.1.5 560,208 11/17/2020
5.1.5-dev-00528 939 11/17/2020
5.1.4 94,509 11/7/2020
5.1.4-dev-00522 994 11/7/2020
5.1.4-dev-00521 999 11/7/2020
5.1.3 1,200,290 8/13/2020
5.1.3-dev-00520 1,057 11/7/2020
5.1.3-dev-00513 997 8/12/2020
5.1.2 684,710 4/27/2020
5.1.2-dev-00508 950 8/12/2020
5.1.2-dev-00501 996 4/27/2020
5.1.1 182,200 4/3/2020
5.1.1-dev-00500 1,059 4/27/2020
5.1.1-dev-00499 990 4/27/2020
5.1.1-dev-00492 1,042 4/3/2020
5.1.0 53,230 3/28/2020
5.1.0-dev-00489 1,040 4/3/2020
5.1.0-dev-00486 1,021 4/3/2020
5.1.0-dev-00485 1,042 4/3/2020
5.1.0-dev-00481 1,043 3/26/2020
5.1.0-dev-00480 1,052 3/26/2020
5.1.0-dev-00479 989 3/25/2020
5.1.0-dev-00478 1,017 3/25/2020
5.1.0-dev-00477 989 3/24/2020
5.0.0 244,501 2/29/2020
5.0.0-dev-00476 1,012 3/24/2020
5.0.0-dev-00473 1,021 3/13/2020
5.0.0-dev-00472 1,001 3/13/2020
5.0.0-dev-00471 1,034 3/13/2020
5.0.0-dev-00464 1,049 2/27/2020
5.0.0-dev-00463 1,096 2/27/2020
4.4.0 247,423 2/7/2020
4.4.0-dev-00453 1,101 2/6/2020
4.4.0-dev-00451 1,050 2/6/2020
4.4.0-dev-00450 1,049 2/6/2020
4.4.0-dev-00447 1,049 2/6/2020
4.4.0-dev-00445 995 2/6/2020
4.4.0-dev-00443 1,334 2/6/2020
4.3.0 263,069 11/18/2019
4.2.1 3,404,997 6/2/2018
4.2.0 20,047 6/1/2018
4.2.0-dev-00366 1,607 6/2/2018
4.2.0-dev-00364 1,510 6/1/2018
4.2.0-dev-00363 1,655 6/1/2018
4.2.0-dev-00360 1,628 6/1/2018
4.2.0-dev-00355 1,760 5/31/2018
4.2.0-dev-00350 1,695 5/28/2018
4.2.0-dev-00349 1,715 5/28/2018
4.1.0 40,826 5/18/2018
4.1.0-dev-00341 1,651 5/18/2018
4.1.0-dev-00340 1,594 5/18/2018
4.1.0-dev-00337 1,624 5/18/2018
4.1.0-dev-00331 1,796 5/15/2018
4.1.0-dev-00326 1,541 5/14/2018
4.1.0-dev-00319 4,025 5/11/2018
4.1.0-dev-00316 1,538 5/11/2018
4.1.0-dev-00311 1,753 5/7/2018
4.1.0-dev-00307 1,684 5/4/2018
4.1.0-dev-00299 1,608 4/27/2018
4.0.1-dev-00294 1,898 4/24/2018
4.0.1-dev-00275 13,103 3/24/2018
4.0.1-dev-00260 6,629 10/18/2017
4.0.1-dev-00258 1,765 10/16/2017
4.0.1-dev-00256 2,006 10/6/2017
4.0.0 763,633 9/30/2017
4.0.0-dev-00247 3,440 7/27/2017
4.0.0-dev-00244 2,850 6/15/2017
4.0.0-dev-00242 1,958 6/13/2017
4.0.0-dev-00236 1,665 6/1/2017
4.0.0-dev-00223 1,713 5/19/2017
4.0.0-dev-00221 1,613 5/17/2017
4.0.0-dev-00220 1,552 5/17/2017
4.0.0-dev-00217 2,814 5/15/2017
4.0.0-dev-00196 2,111 4/6/2017
4.0.0-dev-00194 1,587 4/6/2017
4.0.0-dev-00187 1,633 4/6/2017
4.0.0-dev-00177 1,772 3/24/2017
4.0.0-dev-00175 1,599 3/24/2017
4.0.0-dev-00173 1,607 3/24/2017
3.2.0-dev-00170 1,983 3/24/2017
3.2.0-dev-00168 1,643 3/20/2017
3.2.0-dev-00166 1,806 2/28/2017
3.1.1-dev-00165 1,843 2/28/2017
3.1.1-dev-00162 1,595 2/28/2017
3.1.1-dev-00155 1,641 2/20/2017
3.1.1-dev-00152 1,769 2/7/2017
3.1.1-dev-00151 1,740 1/22/2017
3.1.1-dev-00143 1,706 1/3/2017
3.1.1-dev-00141 1,713 1/2/2017
3.1.0 798,331 12/15/2016
3.0.2-dev-00132 2,271 12/8/2016
3.0.1 16,058 11/23/2016
3.0.1-dev-00123 1,640 11/22/2016
3.0.1-dev-00113 2,057 11/11/2016
3.0.0 109,428 11/3/2016
3.0.0-dev-00109 1,717 11/2/2016
3.0.0-dev-00108 1,695 11/2/2016
3.0.0-dev-00106 1,694 11/2/2016
3.0.0-dev-00105 1,836 11/1/2016
3.0.0-dev-00099 1,866 10/31/2016
3.0.0-dev-00094 2,636 10/3/2016
3.0.0-dev-00093 1,575 10/3/2016
3.0.0-dev-00092 1,628 10/3/2016
2.5.84 111,538 8/23/2016
2.5.80 51,514 7/25/2016
2.5.79 78,361 7/19/2016
2.5.68 13,090 7/1/2016
2.5.66 2,268 6/30/2016
2.5.62 24,425 3/29/2016
2.5.61 38,930 3/22/2016
2.5.59 3,958 3/7/2016
2.5.56 19,272 2/25/2016
2.5.53 97,939 2/3/2016
2.5.40 7,508 1/25/2016
2.5.36 22,423 12/10/2015
2.5.29 42,003 11/7/2015
2.5.28 2,256 11/7/2015
2.5.23 4,283 10/28/2015
2.5.21 42,437 7/6/2015
2.5.18 9,308 6/9/2015
2.5.15 13,420 4/9/2015
2.5.11 68,483 10/26/2014
2.5.10 2,458 10/23/2014
2.5.8 6,990 10/20/2014
2.4.0 62,319 3/19/2013
2.3.1.1 50,429 1/7/2011