MASS4.Graph.Generator 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MASS4.Graph.Generator --version 1.1.0
                    
NuGet\Install-Package MASS4.Graph.Generator -Version 1.1.0
                    
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="MASS4.Graph.Generator" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MASS4.Graph.Generator" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="MASS4.Graph.Generator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MASS4.Graph.Generator --version 1.1.0
                    
#r "nuget: MASS4.Graph.Generator, 1.1.0"
                    
#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.
#:package MASS4.Graph.Generator@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MASS4.Graph.Generator&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=MASS4.Graph.Generator&version=1.1.0
                    
Install as a Cake Tool

MASS4.Graph.Generator

MASS4.Graph.Generator is a compile-time analyzer reference. It targets net10.0 and runs in the .NET 10+ SDK compiler; framework-hosted compiler environments are not supported. It has a private Roslyn dependency and adds no runtime dependency to the core or consumers. Reference Graph.Generator.csproj with OutputItemType="Analyzer" and ReferenceOutputAssembly="false", or install the analyzer package alongside the core and the semantics packages your declarations use.

Declare one [assembly: GraphModule("Your.Namespace.Module", typeof(DataflowNodes))] per assembly. The analyzer supplies internal declaration attributes during post-initialization; they add no public runtime API to the core. Prerequisites are explicit types exposing Register(GraphTypeRegistry); registration never scans assemblies. Declarations are top-level, nongeneric static partial classes. See the shader, FSM and compositor declarations for complete examples.

  • [GraphValue(id, name, typeof(T))] emits a PortType and its dataflow storage binding together. An optional Serializer preserves custom wire formats; JsonContext uses source-generated JsonTypeInfo<T>. A class value gets reference storage and an unmanaged value gets inline storage.
  • [GraphNode(id, name)] emits Type, with ordered [GraphPort(member, key, name, direction, typeof(ValueDeclaration))] declarations. The typed form takes the port's type identity and CLR storage from that [GraphValue] declaration, so source renames follow the symbol and an identity change updates every port. Use [GraphPort(member, key, name, direction, typeId, typeof(T))] only for types declared elsewhere, such as StateFlow. Inputs default to single connections and outputs to multiple; Multiplicity overrides that. Keys.Member exposes the persistent key, and Indices.Member follows declaration order for dataflow, state and control behaviors.
  • [GraphBehavior] emits the corresponding dataflow, control, state or transition binding. Dataflow declarations name a static evaluation method and can declare Volatile and required Features; the generated DataflowNode enforces those features through the backend's normal contract. Other semantics bind an explicit behavior implementation.
  • [GraphPayload(typeof(Payload), JsonContext = typeof(Context), DefaultFactory = nameof(Default))] emits serialization and the optional new-node default. For a single-value payload, use Value = typeof(ValueDeclaration) and Member instead of JsonContext: serialization reuses that value's serializer and constructs the wrapper directly.
  • [GraphSignal] and [GraphRenamedFrom] emit signal identities and rename entries. A signal declaration exposes Type and Raise(graph, instances, instance); transition helpers take that SignalType as their trigger, never a bare identity, so a renamed or removed signal fails at compile time. Renames apply to node and value declarations as well. IDs are always explicit GUIDs; source names never determine persistent identity. Port keys are scoped to their node, preserving existing documents that share keys across node types. New declarations can give every port its own key.
  • [GraphMigration(fromVersion, typeof(Owner), nameof(Owner.Migrate))] emits a migration step. A node with Guard = typeof(BooleanDeclaration) (or GuardType = "boolean-type-guid" for an external type) uses StateNodes.CreateGuardedTransition and automatically emits StateNodes.AddTransitionMigration for its domain identity. Custom transition payloads such as AfterPayload remain independent of that legacy State payload migration.

The generated module implements IGraphTypeModule: registry.Add(new Module()) registers its prerequisites, types, renames and migrations. CreateDataflow, CreateControl and CreateState are emitted when their declarations need those semantics. Value declarations expose Bind(document, compiledGraph, variable) for typed unmanaged or reference handles; writable scopes are Input and External.

Node.Add(editor, payload) returns a handle with typed GraphInput<T> and GraphOutput<T> ports. editor.Connect(source.Out, target.In) only compiles for matching CLR types; explicit conversion nodes bridge differing types. Normal editor validation still checks persistent type identities, multiplicity and graph rules. Transition(editor, from.Exit, to.Enter, payload, SeePlayer.Type, priority) adds and wires a domain transition as one reversible, atomic edit; StateGraphBuilder offers the same typed helpers for the built-in entry, state and transition nodes. Reference outputs expose ReuseMember(context, state, static (previous, state) => ...), so behaviors can reuse their own buffers without a capturing delegate.

Analyzer package

The MASS4.Graph.Generator package contains only analyzers/dotnet/cs/MASS4.Graph.Generator.dll: no runtime library and no dependencies. A user assembly needs the core and this package. Add the semantics packages its behaviors bind to: generated code emits dataflow storage, control or state bindings only when the matching package is referenced. A behavior or guarded transition without its package reports MG5007, naming the package to add. Graph.Samples.CustomNodes is a core-only user assembly, and CI builds it against the freshly packed analyzer.

<PackageReference Include="MASS4.Graph" Version="…" />
<PackageReference Include="MASS4.Graph.Generator" Version="…" PrivateAssets="all" />

Compiled assets

[GraphAsset("Assets/material.graph.json")] public sealed partial class MaterialGraph; compiles a saved asset into an ICompiledGraph. List the file as an AdditionalFiles item. The generator reruns the interpreter's planning at build time: wildcard inference, the slot layout, per-instance caching and the state machine's transition order. It then emits straight-line code. Each node has an ensure method that refreshes its stale sources and calls the declared behavior method directly. Each state's transitions are unrolled in check order, and storage is typed slots in the interpreter's exact layout. No dictionaries, delegates or reflection run per tick, and ticking allocates nothing.

new MaterialGraph(document) binds the loaded asset; MaterialGraph.Backend is an IGraphBackend for hosts and the differential harness. Payloads, variable defaults and trigger identities stay runtime data from the document. Topology does not: another asset, or a changed node, port, edge, variable, variable reference, priority or trigger presence, fails with MG6004 until the project is rebuilt. Assets may use declared value, dataflow, state and transition types, the built-in variable, output, entry, state, transition and guarded-transition nodes, and conversion nodes. Coercions and control flow report MG6002. MG6001 reports a missing file and MG6003 an invalid declaration.

JSON contexts are user-declared with [JsonSerializable], including their naming policies and converters. Roslyn generators cannot see ordinary output from other generators, so the Graph generator consumes the context's generated metadata rather than emitting a context for the JSON generator to discover. Missing metadata fails explicitly during registration. This follows Roslyn's generator execution contract.

Build errors MG5001–MG5005 cover invalid/missing GUIDs, duplicate or still-registered renamed identities, duplicate node-local port keys or member names, malformed conversion shapes and unsupported declaration shapes, including typed ports naming a non-[GraphValue] type and guards whose declaration does not store bool. MG5006 rejects a Serializer that is not a constructible IValueSerializer and a JsonContext without [JsonSerializable] for the value or payload type, which would otherwise fail only at registration. MG5007 reports a missing semantics package. Conflicts across independently compiled assemblies remain registry errors at composition time.

The hand-written sample registrations remain the oracle. Sample tests compare type identities, ordered port declarations, rename entries, migrations, defaults, value/payload JSON, semantics bindings (value storage, conversions, behavior volatility, required features and state roles) and reloads, then run scenarios through independently configured interpreters. The generated FSM fixture uses the hand library's simulated renamedSeePlayer release. Its domain guarded transition is also loaded from a version 1 payload, proving automatic migration registration. Generated-backend tests require each compiled sample asset to match the interpreter observation for observation, with the same instance layout, and the guard to tick 1000 instances without allocating. Generator tests check compiler diagnostics and emitted-code compilation; Graph.AotSmoke verifies registration and persistence in a native executable with JSON reflection disabled.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • net10.0

    • No dependencies.

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.2.0 92 11/4/2026
1.1.0 108 10/29/2026
1.0.0 106 10/28/2026