Facepunch.ActionGraphs 1.9.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Facepunch.ActionGraphs --version 1.9.1                
NuGet\Install-Package Facepunch.ActionGraphs -Version 1.9.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Facepunch.ActionGraphs" Version="1.9.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Facepunch.ActionGraphs --version 1.9.1                
#r "nuget: Facepunch.ActionGraphs, 1.9.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Facepunch.ActionGraphs as a Cake Addin
#addin nuget:?package=Facepunch.ActionGraphs&version=1.9.1

// Install Facepunch.ActionGraphs as a Cake Tool
#tool nuget:?package=Facepunch.ActionGraphs&version=1.9.1                

Facepunch.ActionGraphs

Runtime-composable async methods that can be converted to and from JSON.

Overview

An action graph is made out of nodes, links and variables. Nodes either perform actions or evaluate expressions, and links connect them together to shuttle values or signals around. Variables provide storage local to each invocation of the graph, and are used to capture values at specific points during invocation. Arbitrary user data can be stored on each element, which could be used by a visual editor. Validation is performed to find any errors or warnings, and any errors will mean a graph can't be invoked. Node definitions are stored in a node library, and each graph will belong to exactly one such library to supply its node definitions. Action graphs can be serialized to JSON, and Delegate types created using graphs can also be serialized directly.

Node

Nodes have a definition and a binding. Bindings specify which properties, inputs, and outputs a node has. Inputs and outputs may transmit values or signals. A node with signal inputs / outputs is an Action node, which is invoked when an input signal fires. Nodes without any signal inputs / outputs are Expression nodes, which are lazily evaluated when any of their output values are requested by an Action node.

Nodes

Definition

A node definition describes what the node will do, and provides bindings based on which property values and input types a node currently has. Each definition will belong to exactly one node library, and has a unique name in that library. There are built-in definitions for common nodes like operators, getting / setting variables, and the event node which acts as an entry point.

Binding

Definitions provide bindings, which are specifically typed sets of properties, inputs, and outputs. Depending on the definition, the binding of a node may change as you connect inputs or assign properties. For example, the type of the result output of an op.add addition node depends on the types of the provided inputs.

Property

Properties are constant named values stored in a node, which control its binding. For example: a var.set node, which would set a variable when invoked, has a property specifying which variable it will assign. Changing that property will change the input value type of the node, to match the variable type.

Input

A node input will either receive a signal or a value.

Input values can be provided by another node's output through a Link, or a constant value stored inside the input. Input signals can only be provided by an output signal from another node, and control when the receiving node executes.

If an input value accepts an array type, it may be linked to multiple outputs in a specific order to provide the individual items of an array. Otherwise, inputs link to at most one output.

Output

A node output will emit either a signal or a value.

Output signals may fire mutliple times per invocation of the node, for example the body output of the loop node control.foreach will fire once per element in the items input value. If multiple input signals are connected to the same output signal, the receiving nodes will act as independent concurrent tasks.

Output values of Action nodes may be provided by a specific output signal, and can only be used downstream of that output signal.

Output values of expression nodes are always available, and will be evaluated lazily when requested by an Action node.

Links are the connections between an output and an input. An output signal can only connect to input signals, and an output value can only connect to input values. See input and output for more details.

Variable

Variables are provided as a way to capture values at specific points to be read later on.

Each variable has a specific name and type. They are referenced in var.set and var.get nodes, and must be set before they can be read. They are local to each invocation of an action graph, so if multiple instances of the same graph are running simultaneously they won't share variables.

Node Library

Creating a node library is required to use action graphs. These contain all the node definitions available when building a graph. An ITypeLoader must be provided to wrap any reflection, in case you want to restrict which types can be used in a graph.

There are some built-in special node definitions that are provided by every node library. For example, the event entry point node, var.get and var.set for using variables, and one for each operator like op.add.

Custom Nodes

Custom nodes can be implemented as static C# methods. An [Node( "ident" )] is used for action node methods, and [Node( "ident" ), Pure] for expression node methods. Methods marked with these attributes will be added to a library when calling NodeLibrary.AddAssembly(asm). The parameters of the method will describe the properties, inputs and outputs of the node.

Properties are defined with parameters marked with a [Property] attribute.

Action node methods must return either void or a Task. Expression node methods must return a non-Task, and an output will be generated to emit the return value. Output signals for action nodes are parameters with a delegate type, and they will have corresponding output values based on the delegate parameters. The method can invoke these delegate parameters to emit output signals. If the delegates return Tasks, they will complete when all control flow downstream of the emitted signal has finished.

All other parameters will become inputs for the node. An input with type Input<T> can be evaluated on demand by the method, allowing for input values that change during the invocation of the method. All other input values will be evaluated just before the method is invoked.

Generic methods are largely supported, and will produce a node that can change its binding as input or property types are modified.

User Data

Each main element of an action graph has a UserData property, which can store arbitary named values serialized as JSON nodes. This could be used to record each node's position in a visual editor, for example.

Validation

Each time an action graph is modified, elements will be marked as needing validation. This validation is performed either when attempting to invoke the graph, or when accessing the Messages property. This property will be populated with a list of information, warnings and errors, each describing the context and cause. Any error messages will mean the ActionGraph can't be invoked.

You can also access the messages specific to a particular node / link / property / input / output / variable by using the element.GetMessages() extension method. Accessing this will also cause validation to occur, if any elements have changed since the last validation.

Invocation

After validation succeeds, an action graph can be invoked. Special event nodes act as the entry point during invocation, which can have named parameters that provide output values on the event node. If an action graph is created to match the signature of a particular delegate type, an event node is automatically created with the right output values.

Invocation is asynchronous, and returns a Task that completes when all action nodes have finished acting. If the same action graph instance is invoked multiple times, the separate invocations act in parallel and have their own local variables.

Action graphs can also be converted to delegate instances, as long as they match that delegate's signature. Invoking the delegate will invoke the graph.

Serialization

To be able to serialize action graphs with System.Text.Json, a JsonSerializerOptions instance must have the AddActionGraphConverters() extension method called on it. After that it can convert ActionGraph, ActionGraph<T>, and even delegate instances that are created from action graphs.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.9.2 80 11/11/2024
1.9.1 82 11/11/2024
1.9.0 76 11/8/2024
1.8.53 105 11/6/2024
1.8.52 65 11/6/2024
1.8.51 72 11/5/2024
1.8.50 89 11/5/2024
1.8.49 67 11/5/2024
1.8.48 76 11/4/2024
1.8.47 70 11/4/2024
1.8.46 87 10/31/2024
1.8.45 65 10/31/2024
1.8.44 76 10/31/2024
1.8.43 76 10/30/2024
1.8.42 89 10/25/2024
1.8.41 81 10/25/2024
1.8.40 145 10/18/2024
1.8.39 83 10/8/2024
1.8.38 84 10/8/2024
1.8.37 106 10/8/2024
1.8.36 77 10/7/2024
1.8.35 86 10/7/2024
1.8.34 78 10/7/2024
1.8.33 73 10/7/2024
1.8.32 72 10/7/2024
1.8.31 76 10/7/2024
1.8.30 93 10/7/2024
1.8.29 105 10/3/2024
1.8.28 83 10/2/2024
1.8.27 87 9/30/2024
1.8.26 90 9/26/2024
1.8.25 81 9/26/2024
1.8.24 102 9/26/2024
1.8.23 96 9/25/2024
1.8.22 81 9/25/2024
1.8.21 77 9/25/2024
1.8.20 99 9/23/2024
1.8.19 93 9/20/2024
1.8.18 87 9/20/2024
1.8.17 111 9/20/2024
1.8.16 97 9/19/2024
1.8.15 98 9/18/2024
1.8.14 96 9/18/2024
1.8.13 115 9/18/2024
1.8.12 90 9/18/2024
1.8.11 83 9/17/2024
1.8.10 93 9/17/2024
1.8.9 106 9/17/2024
1.8.8 111 9/17/2024
1.8.7 93 9/17/2024
1.8.6 101 9/16/2024
1.8.5 111 9/13/2024
1.8.4 104 9/13/2024
1.8.3 100 9/13/2024
1.8.2 107 9/13/2024
1.8.1 99 9/13/2024
1.8.0 106 9/13/2024
1.7.18 111 9/12/2024
1.7.17 100 9/12/2024
1.7.16 108 9/11/2024
1.7.15 100 9/11/2024
1.7.14 104 9/11/2024
1.7.13 127 9/10/2024
1.7.12 99 9/6/2024
1.7.11 158 7/2/2024
1.7.10 114 7/2/2024
1.7.9 93 7/1/2024
1.7.8 108 6/10/2024
1.7.7 90 6/10/2024
1.7.6 126 5/25/2024
1.7.5 104 5/25/2024
1.7.4 103 5/25/2024
1.7.3 118 5/21/2024
1.7.2 121 5/16/2024
1.7.1 100 5/3/2024
1.7.0 124 4/30/2024
1.6.21 116 4/22/2024
1.6.20 100 4/20/2024
1.6.19 103 4/20/2024
1.6.18 107 4/18/2024
1.6.17 109 4/18/2024
1.6.16 97 4/18/2024
1.6.15 106 4/17/2024
1.6.14 139 4/10/2024
1.6.13 98 4/10/2024
1.6.12 102 4/10/2024
1.6.11 105 4/8/2024
1.6.10 111 4/2/2024
1.6.9 124 3/20/2024
1.6.8 109 3/19/2024
1.6.7 117 3/18/2024
1.6.6 116 3/16/2024
1.6.5 111 3/16/2024
1.6.4 115 3/16/2024
1.6.3 115 3/16/2024
1.6.2 114 3/16/2024
1.6.1 102 3/16/2024
1.3.103 130 4/8/2024
1.3.102 140 4/3/2024
1.3.101 106 4/3/2024
1.3.100 131 3/22/2024
1.3.99 108 3/22/2024
1.3.98 110 3/22/2024
1.3.97 118 3/22/2024
1.3.96 81 3/22/2024
1.3.95 106 3/22/2024
1.3.94 140 3/11/2024
1.3.93 114 3/11/2024
1.3.92 101 3/11/2024
1.3.91 117 3/11/2024
1.3.90 110 3/8/2024
1.3.89 122 3/7/2024
1.3.88 130 3/5/2024
1.3.87 146 3/1/2024
1.3.86 116 3/1/2024
1.3.85 117 2/29/2024
1.3.84 101 2/29/2024
1.3.83 118 2/29/2024
1.3.82 100 2/29/2024
1.3.81 81 2/29/2024
1.3.80 102 2/29/2024
1.3.79 104 2/28/2024
1.3.78 98 2/28/2024
1.3.77 123 2/28/2024
1.3.76 108 2/28/2024
1.3.75 115 2/28/2024
1.3.74 104 2/27/2024
1.3.73 100 2/27/2024
1.3.72 108 2/26/2024
1.3.71 127 2/26/2024
1.3.70 117 2/26/2024
1.3.69 109 2/26/2024
1.3.68 113 2/26/2024
1.3.67 115 2/23/2024
1.3.66 123 2/22/2024
1.3.65 114 2/20/2024
1.3.64 113 2/20/2024
1.3.63 114 2/20/2024
1.3.62 100 2/19/2024
1.3.61 110 2/19/2024
1.3.60 105 2/16/2024
1.3.59 108 2/16/2024
1.3.58 129 2/15/2024
1.3.57 114 2/15/2024
1.3.56 110 2/15/2024
1.3.55 102 2/15/2024
1.3.54 119 2/14/2024
1.3.53 101 2/14/2024
1.3.52 102 2/14/2024
1.3.51 106 2/14/2024
1.3.50 108 2/14/2024
1.3.49 111 2/13/2024
1.3.48 112 2/11/2024
1.3.47 111 2/10/2024
1.3.46 119 2/10/2024
1.3.45 120 2/9/2024
1.3.44 124 2/9/2024
1.3.43 119 2/8/2024
1.3.42 120 2/8/2024
1.3.41 120 2/8/2024
1.3.40 125 2/7/2024
1.3.39 134 2/7/2024
1.3.38 125 2/7/2024
1.3.37 118 2/6/2024
1.3.36 117 2/6/2024
1.3.35 128 2/6/2024
1.3.34 117 1/31/2024
1.3.33 131 1/30/2024
1.3.32 113 1/30/2024
1.3.31 115 1/30/2024
1.3.30 103 1/30/2024
1.3.29 104 1/30/2024
1.3.28 118 1/29/2024
1.3.27 105 1/29/2024
1.3.26 97 1/29/2024
1.3.25 112 1/27/2024
1.3.24 101 1/26/2024
1.3.23 118 1/26/2024
1.3.22 108 1/26/2024
1.3.21 113 1/26/2024
1.3.20 108 1/25/2024
1.3.19 114 1/25/2024
1.3.18 112 1/25/2024
1.3.17 112 1/25/2024
1.3.16 110 1/24/2024
1.3.15 109 1/24/2024
1.3.14 112 1/24/2024
1.3.13 113 1/23/2024
1.3.12 108 1/23/2024
1.3.11 106 1/23/2024
1.3.10 108 1/23/2024
1.3.9 111 1/23/2024
1.3.8 105 1/23/2024
1.3.7 105 1/23/2024
1.3.6 98 1/22/2024
1.3.5 105 1/22/2024
1.3.4 127 1/19/2024
1.3.3 125 1/19/2024
1.3.2 94 1/19/2024
1.3.1 108 1/19/2024
1.3.0 106 1/19/2024
1.2.10 93 1/19/2024
1.2.9 119 1/18/2024
1.2.8 116 1/18/2024
1.2.7 94 1/18/2024
1.2.6 107 1/18/2024
1.2.5 127 1/17/2024
1.2.4 124 1/16/2024
1.2.3 120 1/16/2024
1.2.2 119 1/16/2024
1.2.1 120 1/16/2024
1.2.0 114 1/16/2024
1.1.37 138 1/13/2024
1.1.36 113 1/13/2024
1.1.35 133 1/12/2024
1.1.34 124 1/12/2024
1.1.33 117 1/12/2024
1.1.32 104 1/12/2024
1.1.31 117 1/12/2024
1.1.30 116 1/11/2024
1.1.29 118 1/11/2024
1.1.28 107 1/11/2024
1.1.27 99 1/11/2024
1.1.26 98 1/11/2024
1.1.25 136 1/11/2024
1.1.24 141 1/9/2024
1.1.23 145 1/8/2024
1.1.22 129 1/8/2024
1.1.21 157 1/5/2024
1.1.20 133 1/4/2024
1.1.19 130 1/4/2024
1.1.18 129 1/4/2024
1.1.17 128 1/4/2024
1.1.16 128 1/4/2024
1.1.15 212 12/7/2023
1.1.14 154 12/7/2023
1.1.13 155 12/6/2023
1.1.12 136 12/4/2023
1.1.11 156 12/2/2023
1.1.10 152 11/27/2023
1.1.9 174 11/24/2023
1.1.8 160 11/24/2023
1.1.7 166 11/22/2023
1.1.6 153 11/22/2023
1.1.5 130 11/21/2023
1.1.4 149 11/21/2023
1.1.3 172 11/17/2023
1.1.2 157 11/16/2023
1.1.1 145 11/16/2023
1.1.0 131 11/15/2023
1.0.17 155 11/8/2023
1.0.16 139 11/8/2023
1.0.15 134 11/7/2023
1.0.14 147 11/6/2023
1.0.13 154 11/1/2023
1.0.12 140 11/1/2023
1.0.11 143 10/31/2023
1.0.10 164 10/31/2023
1.0.9 149 10/31/2023
1.0.8 144 10/30/2023
1.0.7 149 10/27/2023
1.0.6 149 10/27/2023
1.0.5 151 10/27/2023
1.0.4 154 10/27/2023
1.0.3 150 10/25/2023
1.0.2 156 10/24/2023
1.0.1 128 10/24/2023
1.0.0 154 10/24/2023