dotnet-state-machine / stateless

A simple library for creating state machines in C# code
Other
5.41k stars 746 forks source link

Unexpected graph labels for internal transitions #587

Open nightroman opened 5 days ago

nightroman commented 5 days ago

In order to reproduce the issue please use the attached project or use the steps modifying TelephoneCallExample

2024-06-30-0845-TelephoneCallExample.zip

Program.cs - replace this line with this line, to output the graph "TelephoneCallExample.dll.dot"

    File.WriteAllText($"{typeof(Program).Assembly.Location}.dot", phoneCall.ToDotGraph());

PhoneCall.cs - replace these lines with these lines, to add description and graph labels "StartCallTimer", "StopCallTimer"

    .OnEntry(t => StartCallTimer(), "StartCallTimer")
    .OnExit(t => StopCallTimer(), "StopCallTimer")

Run the examples and use the created "TelephoneCallExample.dll.dot"

Expected result

The graph shows internal transition labels like this:

SetVolume / [Function]
MuteMicrophone / [Function]
UnmuteMicrophone / [Function]

Actual result

Internal transition labels for some reason now all labeled as "StartCallTimer":

SetVolume / StartCallTimer [Function]
MuteMicrophone / StartCallTimer [Function]
UnmuteMicrophone / StartCallTimer [Function]

NB Interestingly, there are no overloads for setting custom descriptions / labels for internal transitions (or did I miss?).

Here is the result dot converted to svg. Note unexpected internal transition labels "StartCallTimer": Graphviz

mclift commented 2 days ago

Thanks for taking the time to report your finding, @nightroman!

PR created for review.