Facepunch.ActionGraphs 1.6.21

There is a newer version of this package available.
See the version list below for details.
dotnet add package Facepunch.ActionGraphs --version 1.6.21
NuGet\Install-Package Facepunch.ActionGraphs -Version 1.6.21
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.6.21" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Facepunch.ActionGraphs --version 1.6.21
#r "nuget: Facepunch.ActionGraphs, 1.6.21"
#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.6.21

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

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.7.1 60 5/3/2024
1.7.0 85 4/30/2024
1.6.21 85 4/22/2024
1.6.20 69 4/20/2024
1.6.19 75 4/20/2024
1.6.18 73 4/18/2024
1.6.17 76 4/18/2024
1.6.16 66 4/18/2024
1.6.15 74 4/17/2024
1.6.14 105 4/10/2024
1.6.13 71 4/10/2024
1.6.12 76 4/10/2024
1.6.11 74 4/8/2024
1.6.10 84 4/2/2024
1.6.9 94 3/20/2024
1.6.8 78 3/19/2024
1.6.7 90 3/18/2024
1.6.6 79 3/16/2024
1.6.5 80 3/16/2024
1.6.4 86 3/16/2024
1.6.3 87 3/16/2024
1.6.2 87 3/16/2024
1.6.1 74 3/16/2024
1.3.103 98 4/8/2024
1.3.102 104 4/3/2024
1.3.101 75 4/3/2024
1.3.100 101 3/22/2024
1.3.99 81 3/22/2024
1.3.98 78 3/22/2024
1.3.97 93 3/22/2024
1.3.96 67 3/22/2024
1.3.95 78 3/22/2024
1.3.94 109 3/11/2024
1.3.93 84 3/11/2024
1.3.92 67 3/11/2024
1.3.91 85 3/11/2024
1.3.90 80 3/8/2024
1.3.89 88 3/7/2024
1.3.88 97 3/5/2024
1.3.87 110 3/1/2024
1.3.86 86 3/1/2024
1.3.85 87 2/29/2024
1.3.84 72 2/29/2024
1.3.83 77 2/29/2024
1.3.82 74 2/29/2024
1.3.81 68 2/29/2024
1.3.80 71 2/29/2024
1.3.79 91 2/28/2024
1.3.78 86 2/28/2024
1.3.77 95 2/28/2024
1.3.76 81 2/28/2024
1.3.75 87 2/28/2024
1.3.74 82 2/27/2024
1.3.73 76 2/27/2024
1.3.72 76 2/26/2024
1.3.71 96 2/26/2024
1.3.70 84 2/26/2024
1.3.69 80 2/26/2024
1.3.68 85 2/26/2024
1.3.67 88 2/23/2024
1.3.66 90 2/22/2024
1.3.65 86 2/20/2024
1.3.64 86 2/20/2024
1.3.63 86 2/20/2024
1.3.62 73 2/19/2024
1.3.61 81 2/19/2024
1.3.60 78 2/16/2024
1.3.59 76 2/16/2024
1.3.58 93 2/15/2024
1.3.57 83 2/15/2024
1.3.56 77 2/15/2024
1.3.55 70 2/15/2024
1.3.54 85 2/14/2024
1.3.53 72 2/14/2024
1.3.52 75 2/14/2024
1.3.51 74 2/14/2024
1.3.50 77 2/14/2024
1.3.49 72 2/13/2024
1.3.48 80 2/11/2024
1.3.47 81 2/10/2024
1.3.46 87 2/10/2024
1.3.45 86 2/9/2024
1.3.44 84 2/9/2024
1.3.43 86 2/8/2024
1.3.42 84 2/8/2024
1.3.41 88 2/8/2024
1.3.40 80 2/7/2024
1.3.39 93 2/7/2024
1.3.38 88 2/7/2024
1.3.37 80 2/6/2024
1.3.36 83 2/6/2024
1.3.35 92 2/6/2024
1.3.34 82 1/31/2024
1.3.33 99 1/30/2024
1.3.32 79 1/30/2024
1.3.31 80 1/30/2024
1.3.30 77 1/30/2024
1.3.29 76 1/30/2024
1.3.28 82 1/29/2024
1.3.27 77 1/29/2024
1.3.26 72 1/29/2024
1.3.25 82 1/27/2024
1.3.24 73 1/26/2024
1.3.23 86 1/26/2024
1.3.22 78 1/26/2024
1.3.21 85 1/26/2024
1.3.20 80 1/25/2024
1.3.19 83 1/25/2024
1.3.18 80 1/25/2024
1.3.17 81 1/25/2024
1.3.16 79 1/24/2024
1.3.15 76 1/24/2024
1.3.14 83 1/24/2024
1.3.13 85 1/23/2024
1.3.12 76 1/23/2024
1.3.11 78 1/23/2024
1.3.10 78 1/23/2024
1.3.9 83 1/23/2024
1.3.8 76 1/23/2024
1.3.7 76 1/23/2024
1.3.6 82 1/22/2024
1.3.5 75 1/22/2024
1.3.4 99 1/19/2024
1.3.3 82 1/19/2024
1.3.2 80 1/19/2024
1.3.1 78 1/19/2024
1.3.0 76 1/19/2024
1.2.10 74 1/19/2024
1.2.9 89 1/18/2024
1.2.8 85 1/18/2024
1.2.7 78 1/18/2024
1.2.6 79 1/18/2024
1.2.5 96 1/17/2024
1.2.4 93 1/16/2024
1.2.3 91 1/16/2024
1.2.2 88 1/16/2024
1.2.1 88 1/16/2024
1.2.0 84 1/16/2024
1.1.37 109 1/13/2024
1.1.36 84 1/13/2024
1.1.35 99 1/12/2024
1.1.34 89 1/12/2024
1.1.33 85 1/12/2024
1.1.32 88 1/12/2024
1.1.31 89 1/12/2024
1.1.30 88 1/11/2024
1.1.29 84 1/11/2024
1.1.28 81 1/11/2024
1.1.27 85 1/11/2024
1.1.26 83 1/11/2024
1.1.25 102 1/11/2024
1.1.24 110 1/9/2024
1.1.23 114 1/8/2024
1.1.22 98 1/8/2024
1.1.21 122 1/5/2024
1.1.20 100 1/4/2024
1.1.19 99 1/4/2024
1.1.18 97 1/4/2024
1.1.17 96 1/4/2024
1.1.16 98 1/4/2024
1.1.15 183 12/7/2023
1.1.14 125 12/7/2023
1.1.13 125 12/6/2023
1.1.12 107 12/4/2023
1.1.11 133 12/2/2023
1.1.10 128 11/27/2023
1.1.9 147 11/24/2023
1.1.8 130 11/24/2023
1.1.7 138 11/22/2023
1.1.6 125 11/22/2023
1.1.5 106 11/21/2023
1.1.4 123 11/21/2023
1.1.3 142 11/17/2023
1.1.2 120 11/16/2023
1.1.1 115 11/16/2023
1.1.0 103 11/15/2023
1.0.17 126 11/8/2023
1.0.16 113 11/8/2023
1.0.15 116 11/7/2023
1.0.14 121 11/6/2023
1.0.13 122 11/1/2023
1.0.12 115 11/1/2023
1.0.11 113 10/31/2023
1.0.10 132 10/31/2023
1.0.9 123 10/31/2023
1.0.8 117 10/30/2023
1.0.7 115 10/27/2023
1.0.6 118 10/27/2023
1.0.5 117 10/27/2023
1.0.4 127 10/27/2023
1.0.3 118 10/25/2023
1.0.2 126 10/24/2023
1.0.1 99 10/24/2023
1.0.0 125 10/24/2023