elsa-core/src/modules/Elsa.Workflows.Core/Extensions
Sipke Schoorstra 74fc891350
feat(core): let a container withdraw work it scheduled but must not run (#7967)
A container that schedules a child and then decides the child must not run
had no way to withdraw it. `IActivityScheduler` exposed no removal operation,
and `CancelActivityAsync` no-opped on a context whose status was `Pending`,
so a container could tear a branch down and still have an activity from that
branch execute afterwards, side effects and all. Fixes #7943.

- `IActivityScheduler.RemoveWhere` removes work items and keeps the order the
  survivors would have been taken in; implemented in both the FIFO and LIFO
  schedulers.
- `CancelActivityAsync` (both the public extension and the internal one used
  when a container completes) cancels `Pending` contexts as well as running
  ones, and withdraws the work item that would have started the cancelled
  activity plus the items it had scheduled for children with no context yet.

Withdrawal is a real removal rather than a terminal status honoured at dequeue
time, because the scheduler is also read: `Flowchart.HasPendingWork` inspects
it to decide whether it may complete, and the work item list is extracted into
the persisted workflow state — a withdrawn-but-queued item would be persisted
and rehydrated with a fresh context after a suspend/resume.

`StateMachine` had hand-rolled the same operation to drop competing triggers by
clearing the scheduler and re-scheduling everything else; it now calls
`RemoveWhere`. `Elsa.Bpmn` no longer needs to refuse a teardown whose subtree
still has queued work, so `BpmnWorkTeardown` drops the `NotSupportedException`
and records the teardown reason on the torn-down activity's journal instead.

BREAKING: `IActivityScheduler` gains a member; external implementations must
add `RemoveWhere`.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 23:29:46 +02:00
..
ActivityDescriptorExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
ActivityExecutionContextExtensions.cs feat(core): let a container withdraw work it scheduled but must not run (#7967) 2026-08-20 23:29:46 +02:00
ActivityExecutionContextExtensions.InputEvaluation.cs Protect sensitive workflow inputs 2026-06-01 09:15:34 +02:00
ActivityExecutionContextExtensions.InputOutput.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
ActivityExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
ActivityNodeExtensions.cs
ActivityPropertyExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
ActivityRegistryExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
BackgroundActivityExecutionContextExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
BehaviorCollectionExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
BookmarkExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
BreakBehaviorActivityExecutionContextExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
DictionaryExtensions.cs Update multitenancy logic and improve Result handling: (#7281) 2026-02-11 10:11:12 +01:00
ExpressionEvaluatorExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
ExpressionExecutionContextExtensions.cs Add output converter support at binding boundaries 2026-07-31 04:10:48 +02:00
InputExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
ItemSourceActivityExecutionContextExtensions.cs Add Elsa Script DSL (#7076) 2025-11-25 19:57:50 +01:00
JsonElementExtensions.cs
MemoryBlockReferenceExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
ModuleExtensions.cs Configures Flowchart Execution via DI (#7141) 2025-12-15 10:15:39 +01:00
ObjectExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
OutputConverterServiceCollectionExtensions.cs Add output converter support at binding boundaries 2026-07-31 04:10:48 +02:00
OutputExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
PipelineContributorExtensions.cs Enhance console logging with improved context and lifecycle (#7536) 2026-05-27 00:14:28 +02:00
ServiceCollectionExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
TriggerExtensions.cs Refactor activity context management and state handling. 2025-01-28 20:24:53 +01:00
VariableCollectionExtensions.cs
VariableExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
WorkflowBuilderExtensions.cs Update namespaces and correct merge artefacts 2024-10-11 20:41:49 +02:00
WorkflowExecutionContextExtensions.cs Adds activity execution call stack support (#7271) 2026-02-24 15:23:59 +01:00
WorkflowExecutionResultExtensions.cs Enhance WorkflowTestFixture and RunJavaScript tests with additional examples and helper methods 2025-10-21 20:36:24 +02:00
WorkflowExtensions.cs Refactors extension methods to instance methods (#7089) 2025-11-25 14:53:18 +01:00
WorkflowRunnerExtensions.cs Update namespaces and correct merge artefacts 2024-10-11 20:41:49 +02:00