Skip to content

Restore synchronous PermittedTriggers for sync-only state machines#647

Open
mclift wants to merge 1 commit into
dotnet-state-machine:devfrom
mclift:maint/634-permitted-triggers-sync-async
Open

Restore synchronous PermittedTriggers for sync-only state machines#647
mclift wants to merge 1 commit into
dotnet-state-machine:devfrom
mclift:maint/634-permitted-triggers-sync-async

Conversation

@mclift
Copy link
Copy Markdown
Member

@mclift mclift commented Apr 4, 2026

This PR revisits the deprecation of synchronous PermittedTriggers/GetPermittedTriggers discussed in #634. After concerns were raised about marking these members for deprecation, the goal is to keep synchronous introspection available for fully synchronous workflows, while making the async boundary explicit when async guard evaluation is actually required.

Note that this change introduces a new exception condition: InvalidOperationException is thrown when PermittedTriggers/GetPermittedTriggers is used on a state that has async triggers.

  • Restored a native synchronous implementation of PermittedTriggers and GetPermittedTriggers
  • Removed the blocking wrapper that routed sync calls through GetPermittedTriggersAsync
  • Added detection for whether permitted-trigger evaluation requires async guard evaluation in the current state hierarchy
  • Changed synchronous permitted-trigger enumeration to throw a clear InvalidOperationException when async guards are present in the current state or one of its superstates
  • Kept GetPermittedTriggersAsync as the full-fidelity API for all configurations
  • Updated ToString() to use the synchronous path when async guard evaluation is not needed and fall back to async permitted-trigger enumeration only when required

@mclift mclift changed the title #634 Restore synchronous PermittedTriggers for sync-only state machines Restore synchronous PermittedTriggers for sync-only state machines Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant