Skip to content

Async state machine 'Start' called on a copy of the state machine #20606

@sharwell

Description

@sharwell

Version Used: 15.3 Preview 3

Steps to Reproduce:

  1. Create a custom task-like type with the method builder implemented as a struct
  2. In the Start<TStateMachine> method, set the value of a field of the method builder
  3. In the SetResult method, read the value of the field

Expected Behavior:

The value read in SetResult will match the value written to the field in Start<TStateMachine>.

Actual Behavior:

The value read in SetResult is the value of the field at the point Create() returned.

Cause:

The Start<TStateMachine> method is called on a copy of the builder on the stack instead of calling it on the instance returned from Create().

Workaround:

Set the state in Create() instead of Start<TStateMachine>.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions