Repository navigation
State Machine State identity
State is uniquely represented within State Machine by string name. That rule applies to all States, defined both styles - lambda and typed. Both definition styles can interact freely, but it is important for States to be referred to (as Transition targets) by a proper name.
Important!
If you are using multiple classes that are implementing different parts of State's logic, you must remember which one is actually representing the State - the one used inAddState<>()method. Classes referenced inAddOnEntry<>()/AddOnExit<>()methods calls are not considered States that can be referred as Transition targets.
In lambda-style definition, State name is given explicitly. In typed-style definition, State class' full name is used as State name by default. This can be overriden by using explicit name for typed States:
public class TypedState : IState
{ }
public class StringNamedState : IState
{ }Definition fragment (inside the builder callback):
/* fragment of State Machine definition */
.AddState<TypedState>(b => b
.AddDefaultTransition("stringNamed")
)
// this State is identified as "stringNamed", so this string name must be used in above Transition
.AddState<StringNamedState>("stringNamed")Sometimes it may become handy to refer to typed States by string. In such cases, following technique should be used:
public class TypedState : IState
{ }Definition fragment (inside the builder callback):
/* fragment of State Machine definition */
.AddState("lambdaState", b => b
// to obtain name that identifies TypedState, State<T>.Name should be used
.AddDefaultTransition(State<TypedState>.Name)
// ...this is possible also for State types available as value
.AddDefaultTransition(State.GetName(typeof(TypedState)))
)
.AddState<TypedState>()Home page Support Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0. © by Mikołaj Milewski, 2026
Overview
Installation
Runtimes
Orleans runtime
Concepts
Events and Structural Events
Messaging Patterns
Validation
Scheduling
Observability
Behaviors
Behavior Values
Dependency Injection
Behavioral Groups
State Machines
Concepts
State Identity
In-State Event Deferrals
Evaluation of Transitions
Exception Handling
Building blocks
Regions
States
State
Composite State
Orthogonal State
Final State
Pseudostates
Choice
Junction
Fork
Join
History
Transitions
Transition
Default Transition
Internal Transition
Activities
Concepts
Exception Handling
Implicit Fork and Join
Tokens
Building blocks
Nodes
Action Node
Decision Node
Merge Node
Initial Node
Final Node
Input Node
Output Node
Fork Node
Join Node
Accept Event Action Node
Send Event Action Node
Publish Event Action Node
Time Event Action Node
Data Store Node
Structured Activity Node
Iterative Activity Node
Parallel Activity Node
Flows
Data Flow
Control Flow
Actions
Entities
Fields
Mutations
Projections
Extensions
ClearScript
FluentValidation
JSON definitions
Minimal APIs
OneOf
OpenTelemetry
PlantUML
Scheduling