Vixen
02b45cc4
csharp
public sealed class NodeTypeGenerator

Turns [Node]-attributed classes into a node library.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

What it writes. For each node class: a Definition describing its ports, and the Bind override that fills its port fields from what the compiler resolved. For each assembly: one NodeTypes.Register listing every definition in it.

Why generated rather than reflected. The obvious implementation walks the loaded assemblies looking for the attribute, and costs a reflection pass at startup, an AOT hazard, and a library whose contents depend on what happened to be loaded. Generating it costs a build step and makes the library a compile-time fact — which is also what lets Create be a new rather than an Activator call.

Why the port metadata comes from the same text as the fields. A node's ports could have been declared in the attribute and its fields written by hand to match. They would then be two lists that have to agree, and a port renamed in one place is an edge that silently stops arriving. Reading both off one declaration is the only arrangement where that cannot happen.

Methods (1)

  • public void Initialize(IncrementalGeneratorInitializationContext context)

    Called to initialize the generator and register generation steps via callbacks on the