Skip to content

Commit 2684fdd

Browse files
committed
Prepare v5.17.0.
1 parent d3b8b09 commit 2684fdd

File tree

4 files changed

+45
-8
lines changed

4 files changed

+45
-8
lines changed

CHANGELOG.md

+20
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## 5.17.0 - 2024.12.30
8+
### Changed
9+
- Use `PackageLicenseExpression` in csproj file [#583], [#584]
10+
### Added
11+
- Added mermaid graph support [#585]
12+
- Allow PermitDynamic destination state to be calculated with an async function (Task) [#595]
13+
- Updated readme to clarify re-entry behaviour of dynamic transitions [#604]
14+
- Added .NET 9.0 to build targets [#610]
15+
### Fixed
16+
- Unexpected graph labels for internal transitions [#587]
17+
- Labels not escaped in `UmlDotGraphStyle` [#597]
18+
719
## 5.16.0 - 2024.05.24
820
### Changed
921
- Permit state reentry from dynamic transitions [#565]
@@ -222,6 +234,14 @@ Version 5.10.0 is now listed as the newest, since it has the highest version num
222234
### Removed
223235
### Fixed
224236

237+
[#610]: https://github.com/dotnet-state-machine/stateless/pull/610
238+
[#604]: https://github.com/dotnet-state-machine/stateless/issues/604
239+
[#597]: https://github.com/dotnet-state-machine/stateless/pull/597
240+
[#595]: https://github.com/dotnet-state-machine/stateless/pull/595
241+
[#587]: https://github.com/dotnet-state-machine/stateless/pull/589
242+
[#585]: https://github.com/dotnet-state-machine/stateless/issues/585
243+
[#584]: https://github.com/dotnet-state-machine/stateless/pull/584
244+
[#583]: https://github.com/dotnet-state-machine/stateless/pull/583
225245
[#575]: https://github.com/dotnet-state-machine/stateless/pull/575
226246
[#574]: https://github.com/dotnet-state-machine/stateless/pull/574
227247
[#570]: https://github.com/dotnet-state-machine/stateless/pull/570

README.md

+23-6
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ Trigger parameters can be used to dynamically select the destination state using
144144

145145
### Ignored Transitions and Reentrant States
146146

147-
Firing a trigger that does not have an allowed transition associated with it will cause an exception to be thrown.
147+
In Stateless, firing a trigger that does not have an allowed transition associated with it will cause an exception to be thrown. This ensures that all transitions are explicitly defined, preventing unintended state changes.
148148

149149
To ignore triggers within certain states, use the `Ignore(TTrigger)` directive:
150150

@@ -153,7 +153,7 @@ phoneCall.Configure(State.Connected)
153153
.Ignore(Trigger.CallDialled);
154154
```
155155

156-
Alternatively, a state can be marked reentrant so its entry and exit actions will fire even when transitioning from/to itself:
156+
Alternatively, a state can be marked reentrant. A reentrant state is one that can transition back into itself. In such cases, the state's exit and entry actions will be executed, providing a way to handle events that require the state to reset or reinitialize.
157157

158158
```csharp
159159
stateMachine.Configure(State.Assigned)
@@ -167,6 +167,23 @@ By default, triggers must be ignored explicitly. To override Stateless's default
167167
stateMachine.OnUnhandledTrigger((state, trigger) => { });
168168
```
169169

170+
### Dynamic State Transitions and State Re-entry
171+
172+
Dynamic state transitions allow the destination state to be determined at runtime based on trigger parameters or other logic.
173+
174+
```csharp
175+
stateMachine.Configure(State.Start)
176+
.PermitDynamic(Trigger.CheckScore, () => score < 10 ? State.LowScore : State.HighScore);
177+
```
178+
179+
When a dynamic transition results in the same state as the current state, it effectively becomes a reentrant transition, causing the state's exit and entry actions to execute. This can be useful for scenarios where the state needs to refresh or reset based on certain triggers.
180+
181+
```csharp
182+
stateMachine.Configure(State.Waiting)
183+
.OnEntry(() => Console.WriteLine($"Elapsed time: {elapsed} seconds..."))
184+
.PermitDynamic(Trigger.CheckStatus, () => ready ? State.Done : State.Waiting);
185+
```
186+
170187
### State change notifications (events)
171188

172189
Stateless supports 2 types of state machine events:
@@ -183,7 +200,7 @@ This event will be invoked every time the state machine changes state.
183200
```csharp
184201
stateMachine.OnTransitionCompleted((transition) => { });
185202
```
186-
This event will be invoked at the very end of the trigger handling, after the last entry action has been executed.
203+
This event will be invoked at the very end of the trigger handling, after the last entry action has been executed.
187204

188205
### Export to DOT graph
189206

@@ -207,9 +224,9 @@ digraph {
207224
This can then be rendered by tools that support the DOT graph language, such as the [dot command line tool](http://www.graphviz.org/doc/info/command.html) from [graphviz.org](http://www.graphviz.org) or [viz.js](https://github.com/mdaines/viz.js). See http://www.webgraphviz.com for instant gratification.
208225
Command line example: `dot -T pdf -o phoneCall.pdf phoneCall.dot` to generate a PDF file.
209226

210-
### Export to mermaid graph
227+
### Export to Mermaid graph
211228

212-
It can be useful to visualize state machines on runtime. With this approach the code is the authoritative source and state diagrams are by-products which are always up to date.
229+
Mermaid graphs can also be generated from state machines.
213230

214231
```csharp
215232
phoneCall.Configure(State.OffHook)
@@ -226,7 +243,7 @@ stateDiagram-v2
226243
OffHook --> Ringing : CallDialled
227244
```
228245

229-
This can then be rendered by GitHub or [Obsidian](https://github.com/obsidianmd)
246+
This can be rendered by GitHub markdown or an engine such as [Obsidian](https://github.com/obsidianmd).
230247

231248
``` mermaid
232249
stateDiagram-v2

src/Stateless/Stateless.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Description>Create state machines and lightweight state machine-based workflows directly in .NET code</Description>
99
<Copyright>Copyright © Stateless Contributors 2009-$([System.DateTime]::Now.ToString(yyyy))</Copyright>
1010
<NeutralLanguage>en-US</NeutralLanguage>
11-
<VersionPrefix>5.16.0</VersionPrefix>
11+
<VersionPrefix>5.17.0</VersionPrefix>
1212
<Authors>Stateless Contributors</Authors>
1313
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
1414
<GenerateDocumentationFile>true</GenerateDocumentationFile>

src/Stateless/docs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Some useful extensions are also provided:
4141
* Ability to store state externally (for example, in a property tracked by an ORM)
4242
* Parameterised triggers
4343
* Reentrant states
44-
* Export to DOT graph
44+
* Export to DOT and Mermaid graph
4545

4646
## Documentation
4747

0 commit comments

Comments
 (0)