Skip to content

Extension PlantUML

Mikołaj Milewski edited this page Oct 27, 2026 · 1 revision

PlantUML

Stateflows.Extensions.PlantUml generates PlantUML text for registered State Machine and Activity definitions. The package adds inspection interceptors and handles PlantUmlInfoRequest events.

Register the extension with Stateflows:

services.AddStateflows(stateflows => stateflows
    .AddPlantUml()
    .AddStateMachines(machines => machines
        .AddStateMachine<Order>()));

Send a PlantUmlInfoRequest to a State Machine or Activity instance that can be inspected. Its response is a PlantUmlInfo containing the generated PlantUML string and convenience PNGUrl / SVGUrl links.

Those image links point to the public plantuml.com server and include the encoded diagram in the URL. Avoid sharing those links for diagrams containing sensitive information; render the returned PlantUML with a trusted local or privately hosted PlantUML server when needed. The extension source is available here.

Request a diagram

For a located IStateMachineBehavior or IActivityBehavior named behavior:

using Stateflows.Common;
using Stateflows.Extensions.PlantUml.Events;

var result = await behavior.RequestAsync<PlantUmlInfo>(new PlantUmlInfoRequest());
if (result.Status != EventStatus.Consumed || result.Response is null)
{
    throw new InvalidOperationException($"Diagram request failed: {result.Status}.");
}

await File.WriteAllTextAsync("behavior.puml", result.Response.PlantUml);

PlantUmlInfoRequest does not implicitly initialize a Behavior. Initialize the instance through its normal lifecycle before requesting a diagram when required. Reading PlantUml and writing it locally does not contact the public image server; do not fetch PNGUrl or SVGUrl for private models.

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

Clone this wiki locally