Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#553 Add NuGet package README; update compatibility statement in READ… #555

Merged
merged 1 commit into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ Setting this is vital within a Microsoft Orleans Grain for example, which requir

## Building

Stateless runs on .NET 4.0+ and practically all modern .NET platforms by targeting .NET Standard 1.0 and .NET Standard2.0. Visual Studio 2017 or later is required to build the solution.
Stateless runs on .NET runtime version 4+ and practically all modern .NET platforms by targeting .NET Framework 4.6.2, .NET Standard 2.0 and .NET 8.0. Visual Studio 2017 or later is required to build the solution.


## Contributing
Expand All @@ -256,5 +256,3 @@ This page is an almost-complete description of Stateless, and its explicit aim i
Please use the issue tracker or the if you'd like to report problems or discuss features.

(_Why the name? Stateless implements the set of rules regarding state transitions, but, at least when the delegate version of the constructor is used, doesn't maintain any internal state itself._)

[Visual Studio 2015 and .NET Core]: https://www.microsoft.com/net/core
5 changes: 5 additions & 0 deletions src/Stateless/Stateless.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup Label="SourceLink">
Expand All @@ -45,4 +46,8 @@
<ItemGroup Label="SourceLink">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
</ItemGroup>

<ItemGroup>
<None Include="docs\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>
</Project>
56 changes: 56 additions & 0 deletions src/Stateless/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Stateless

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

```csharp
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)](https://web.archive.org/web/20170814020207/http://simplestatemachine.codeplex.com/).

## 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](https://github.com/dotnet-state-machine/stateless?tab=readme-ov-file#stateless----)
contains documentation and code examples. The source repository also includes a few
[example projects](https://github.com/dotnet-state-machine/stateless/tree/dev/example).

## Contributing

We welcome contributions to this project. Check
[CONTRIBUTING.md](https://github.com/dotnet-state-machine/stateless/blob/dev/CONTRIBUTING.md) for more info.