dotnet-state-machine / stateless

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

Unexpected graph labels for internal transitions #587

Open nightroman opened 4 months ago

nightroman commented 4 months 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 4 months ago

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

PR created for review.