SimpleFSM 1.0.0

dotnet add package SimpleFSM --version 1.0.0                
NuGet\Install-Package SimpleFSM -Version 1.0.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="SimpleFSM" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleFSM --version 1.0.0                
#r "nuget: SimpleFSM, 1.0.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.
// Install SimpleFSM as a Cake Addin
#addin nuget:?package=SimpleFSM&version=1.0.0

// Install SimpleFSM as a Cake Tool
#tool nuget:?package=SimpleFSM&version=1.0.0                

SimpleFSM

This FSM uses Enum to keep track of states and Functions to handler the transitions from one state to another.

This Enum keeps track of the state:

public enum TestStates
{
    Start,
    Step1,
    Step2,
    Step3,
    End
}

Payload class:

public class TestPayload
{
    public string Value { get; set; }
}

Building the FSM using the builder:

var paylod = new TestPayload();

var fsm = SimpleFsmBuilder<TestStates, TestPayload>.New()
    // Set start state
    .SetStartState(TestStates.Start)
    // Set end state
    .SetEndState(TestStates.End)
    // Add un-conditional transition from Start to Step1
    .AddTransition(TestStates.Start, TestStates.Step1)

    // Add Handler from step1 -> Step2
    .AddHandler(TestStates.Step1, (currentState, payload) =>
    {
        payload.Value = "Test1";
        // Destination state
        return TestStates.Step2;
    })
    // Add Handler from Step2 -> Step3
    .AddHandler(TestStates.Step2, (currentState, payload) =>
    {
        payload.Value = "Test2";
        // Destination state
        return TestStates.Step3;
    })
    // Add Handler from Step3 -> End
    .AddHandler(TestStates.Step3, (currentState, payload) =>
    {
        payload.Value = "Test3";
        // Destination state
        return TestStates.End;
    })
    // Add Exception handler
    .SetExceptionHandler((currentState, payload, exception) =>
    {
        // Validate the exception
        Assert.Equal(expectedException, exception);
        // Stop
        return TestStates.End;
    })    
    .Build();

// Run the machine given the payload
fsm.Start(paylod);
// or fsm.StartAsync(paylod)
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 was computed.  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. 
.NET Core netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 2.1

    • 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
1.0.0 919 8/19/2018