How uipath/corewf works
This project is a port of the Windows Workflow Foundation (WF) to .NET 6 – essentially a workflow engine that supports activities written either in code or (more commonly) in XAML. It reimplements many of the core WF runtime components (execution, tracking, persistence, XAML parsing/integration) for .NET 6, and even provides support for Visual Basic integration as well as comprehensive test and performance harnesses.
Main Components
• Workflow Runtime Engine:
– This is the heart of the system and lives mainly in the “UiPath.Workflow.Runtime” directory. Key classes include WorkflowApplication, WorkflowInvoker, and the various runtime “WorkItem” processing classes.
– Include the process for loading a workflow (using ActivityXamlServices from the XAML integration layer) and invoking it.
• XAML Integration Layer:
– The “System.Xaml” directory and related code are integral for parsing and loading workflow definitions written in XAML.
• Activity and Expression Infrastructure:
– The “UiPath.Workflow” and “Expressions” portions (as well as the code in “CoreWf.EtwTracking” for event tracing) define the activities, expression evaluation, and metadata needed to execute workflows.
– Note that there’s support for both C# and Visual Basic, with VisualBasic-related code under the “VisualBasic” directory.
• Persistence and Durable Instancing:
– Point out the durable instancing modules (within “UiPath.Workflow.Runtime/DurableInstancing”) that handle saving/loading workflow state and participating in persistence.
• Tracking and Diagnostics:
– Include modules for tracking (found in both “UiPath.Workflow.Runtime/Tracking” and “CoreWf.EtwTracking”) which capture execution events, activity states, and performance diagnostics.
• Test, Benchmarks, and Utility Modules:
– The “Test” directory contains extensive test harnesses (unit tests, performance benchmarks, workflow test cases, etc.) that ensure the reliability and conformance of the engine.
Relationships and Interactions
• Workflow Definition & Loading:
– Show how a workflow definition (either created programmatically or authored in XAML) is first loaded by ActivityXamlServices in the XAML integration layer.
• Runtime Execution:
– The loaded workflow is then passed to the runtime engine (WorkflowInvoker/WorkflowApplication) where the engine proceeds to execute activities.
– Illustrate the flow between execution, the handling of activities (including nested and composite activities), and the propagation of control signals (begin, suspend, resume, terminate).
• Persistence & Recovery:
• Tracking & Diagnostics:
• Expression Evaluation & Compiler Integration:
• Testing/Performance:
– Illustrate that various tests (unit tests, benchmarks, and custom test harness applications) inject workflows into the runtime engine to verify behavior.
Architectural Patterns & Design Principles
• Modularity: The project is broken up into logical components (runtime, XAML integration, persistence, tracking, tests, etc.) that interact via well-defined interfaces.
• Separation of Concerns: The runtime focuses on execution, while the XAML/parsing layer and expression evaluators handle workflow definition interpretation.
• Extensibility: The presence of various “Configurer” and “Extension” classes indicates that the system is designed to be extended (e.g., custom tracking participants, custom activities, expression evaluators).
Detail Every Essential Architectural Element
• Don’t be afraid to over-segment:
• Workflow life-cycle: from definition (and design) through to load, execute, state persist, track, and complete/terminate.