# Codegen Generators

## Stability

Internal / Unsupported

## Scope

Explains how each generator works, what it produces, and the checks to run when outputs are missing.

## Quick map

\| Generator | Primary output | Run when |

\| --- | --- | --- |

\| Custom Type Generator | Blackboard bucket/serializer, Flow Get/Set data, drawer | New blackboard types |

\| Enum Resolver Generator | Enum bucket/serializer + serializer registry | New enums used by blackboard/UI |

\| Member Generator | Instruction/Condition data from API members | Exposing methods/fields/properties |

\| Registry Generator | Registries for instructions/conditions/enums/drawers | After any generator that adds new types |

## Decision guide (most common)

* New data type in blackboard → Custom Type Generator → Registry Generator.
* Enum not showing in UI → Enum Resolver Generator → Registry Generator.
* API method not visible as instruction → Member Generator → Registry Generator.

## Custom Type Generator

### When to use

When you need a custom blackboard type to be stored, serialized, and used by Flow Get/Set data.

### Required tags

* `[FlowCustomType]` on class/struct (optional if settings allow non-tag types).
* `[FlowComponentReference]` on Component types to generate `ComponentReference<T>` bucket/serializer/nodes/drawer.
* `[NoFlowAutoUI]` skips code generation for the tagged type.

### Key settings

* Output Folder / Base Namespace
* Include Non FlowCustomType Types
* Include Unity/System Types
* Default Category
* Default Generate Bucket / Serializer / Flow Nodes / Drawer

### Outputs

* `OutputRoot/Runtime/G` and `OutputRoot/Editor/G`
* Runtime/editor asmdefs scoped to `RootNamespace.G.Runtime` and `.Editor`
* Blackboard bucket + serializer + Flow Get/Set data + blackboard drawer (per `FlowCustomType` flags)
* Serializer registry group (`.rg.cs`)

### Common issues

* Type skipped: abstract, open generic, editor-only, or enum types are not supported.
* Type skipped: `UnityEngine.Object`-derived types (e.g., `MonoBehaviour`, `ScriptableObject`) are not supported.
* Type skipped: technical infrastructure types, invalid data shapes, already-generated outputs, or symbol conflicts are filtered before Available/Candidate lists.
* Component types: use `[FlowComponentReference]` to generate `ComponentReference<T>` instead of generating the component type directly.
* UI not generated: `[NoFlowAutoUI]` disables auto generation for the type.
* Missing serializer: ensure GenerateSerializer is enabled in the attribute or defaults.
* Cross-assembly output reuse counts as satisfied only when a generated item already exists in the built-in output, current output, or project-wide lookup scope.

## Enum Resolver Generator

### When to use

When enums are used in Switch/Flags nodes, blackboard values, or UI dropdowns.

### Required tags

* `[FloweCustomEnum]` on enum, or enable settings that include enums without attributes.

Note: the enum attribute name is `FloweCustomEnum` (spelled with an extra `e`).

### Key settings

* Enable Default Enum Whitelist (FlowCore namespace)
* Include Enums Without Attribute
* Include Unity/System Enums

### Outputs

* `OutputRoot/Runtime/G` and `OutputRoot/Editor/G`
* Enum bucket + serializer
* Serializer registry group (`.rg.cs`)

### Common issues

* Enum missing in dropdowns: run Enum Resolver Generator then Registry Generator.
* Enum excluded: check whitelist flags and `[FloweCustomEnum]` tag.
* Enum skipped: editor-only, script-guarded editor-only, non-runtime-assembly, and inaccessible enums are excluded.
* Already-generated enum resolvers are detected through the shared generated lookup used by Member and Registry flows.

## Member Generator

### When to use

When you want to expose existing C#/Unity APIs as instructions and conditions.

### Required tags

* `[FlowTypeGen]` to scan all members on a type.
* `[FlowMemberGen]` to include specific methods/properties/fields.
* `[FlowMemberGenExclude]` to remove a type or member from generation.

### Key settings

* Output Folder / Base Namespace
* Include Types Without Attribute
* Include Unity/System Types
* Default Type Whitelist groups

### Outputs

* `OutputRoot/I/Runtime/G` and `OutputRoot/C/Runtime/G` (editor-only types go to `Editor/G`)
* Runtime/editor asmdefs scoped to `{RootNamespace}.Instruction.G.*` and `.Condition.G.*`
* Instruction and condition data types that mirror methods/fields/properties

### Component/GameObject dual variants

* Component members generate fixed dual variants: a `Component` variant and a `GameObject` variant.
* The `Component` variant preserves the original API type contract. Component-typed `Target`, method parameters, property setter `Value`, and getter/method write-back all use the concrete component `FlowValueGet*` / `FlowValueSet*` wrappers.
* The `GameObject` variant downgrades every component-typed input/output slot to a `GameObject` route. The generated data exposes `GameObject`, `Scope`, `IncludeInactive`, and `Index`.
* `Index` defaults to `0`. `0` uses single-component lookup, while `> 0` uses multi-component lookup and resolves the zero-based indexed result.
* Component outputs in the `GameObject` variant write back through `FlowValueSetGameObjectData` using `resolvedComponent?.gameObject`. Component identity and index are not preserved in the write-back contract.
* Failure semantics stay version-specific: instructions warn and continue, conditions warn and return `false`.
* `ref` / `out` component parameters are not downgraded to the `GameObject` route in this iteration. They remain on the component contract.

### UI notes

* Member entries labeled `Auto` are auto-selected because the type has `[FlowTypeGen]` or the member has `[FlowMemberGen]`.
* `Auto` entries are locked (greyed) in the candidate list. They are not generated until you run the generator.
* `Ready` means the selected member can generate immediately with current wrappers/resolvers.
* `Needs Remedial` means the member is visible and remediable, but still depends on missing generated data.

### Wrapper requirements

* Member Generator requires FlowValue wrappers for targets, parameters, and return values.
* Scalar component slots prefer direct component FlowValue wrappers. Only list-shaped component data continues to use the `ComponentReference<T>` route.
* For component members, wrapper selection follows the generated variant contract. `Component` variants require concrete component `FlowValueGet*` / `FlowValueSet*` wrappers, while `GameObject` variants require the `GameObject` wrappers plus the search metadata fields.
* `GameObject` is resolved via `GameObjectReference` (no custom type needed).

### Remedial dependency preflight

When generation detects real missing data types (FlowValue wrappers or enum resolvers), the preflight runs in stages:

* Stage 1: missing enum resolvers are checked first.
* Stage 2: missing custom types are checked only after enum dependencies pass or are force-skipped.
* Stage 3: the normal generate confirmation appears only when no remedial dialog remains.
* **Remedial Generation**: stops the current stage, stores the missing items in the session, and opens the required generator in a focused remedial mode.
  * Missing enums open Enum Resolver Generator first.
  * Missing custom types open Custom Type Generator only after enum remediation is clear or force-skipped.
  * The opened CT/Enum window replaces normal candidates with the current missing items for this remedial session.
  * Scalar component dependencies are remediated against the actual member contract instead of being silently rewritten to `ComponentReference<T>`. List component dependencies still follow the `ComponentReference<T>` route.
* **Force Generate**: continues generation and skips members that cannot be resolved.
  * A member is skipped if any parameter/return/target lacks a wrapper.
  * A member is skipped if its enum resolver is missing.
  * If the current selection has zero direct-generatable members, generation is blocked instead of silently producing no outputs.

Note: only already-generated outputs count as satisfied. Candidate or pending entries do not. Types with no visible members are not shown in Available/Candidate lists.

### Common issues

* Missing outputs: check attribute tags, whitelist settings, or editor-only types.
* Missing value write-back: FlowValue wrapper for the target type may be unavailable.
* Build errors from missing runtime API: the generator skips members that fail runtime support checks, plus a small hardcoded blacklist in `FlowMemberGeneratorTypeUtility.IsKnownEditorOnlyMember` (currently `UnityEngine.UI.Graphic.OnRebuildRequested` and `UnityEngine.UI.Text.OnRebuildRequested`).

Tip: If you need custom types as parameters, run Custom Type Generator first to create FlowValue wrappers.

## Registry Generator

### When to use

After adding or regenerating instructions, conditions, enums, or drawers.

### Key settings

* Output folders / namespaces for Instruction, Condition, Enum, and Drawer registries

### Outputs

* `OutputRoot/*/Runtime/*.rg.cs` and `OutputRoot/*/Editor/*.rg.cs`
* Registry groups used by editor/runtime lookups
* The `Available Generated Enum Resolvers` section aggregates generated enum resolver outputs. It does not scan raw enum declarations directly.

### Common issues

* Empty registry: ensure generators ran and types compile in runtime assemblies.
* `Enum Resolvers = 0` can be normal when no generated enum resolver outputs exist yet. Run Enum Resolver Generator first if you expect entries here.

## Validation checklist

* New types appear in node search and dropdowns.
* Generated Items lists the new outputs.
* Registries compile without missing references.

## Related

* [Codegen Pipeline](/flow-core-docs/documentation/api-extension-guide/codegen-pipeline.md)
* [Built-in Catalog Overview](/flow-core-docs/documentation/reference/built-in-catalog-overview.md)
* [Generated Items](/flow-core-docs/documentation/api-extension-guide/generated-items.md)
* [Auto UI Tags](/flow-core-docs/documentation/reference/auto-ui-tags.md)
* [Extension Points](/flow-core-docs/documentation/api-extension-guide/extension-points.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://flow-core.gitbook.io/flow-core-docs/documentation/api-extension-guide/codegen-generators.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
