Vixen
feb85697
csharp
public sealed class DeclaredRegistrationGenerator

Turns an assembly's declaration attributes into one Declared.Register(PluginContext).

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

Remarks

Doc 36 § D3's in-tree half, which was designed and never built, and doc 50 § D5. The attributes — [EditorMenu], [EditorSubmenu], [CustomInspector], [CustomDrawer], [EditorTool], [CreateAssetMenu], [Overlay], [DrawGizmo] and [EditorIcon] — were read by a bounded reflective scan of a plugin's or a script's assembly and by nothing else, so an in-tree module that wrote one got nothing, and no in-tree module wrote one. This writes the registration at compile time: no reflection, ADR-002 intact, and a module's Activate calls it in one line.

⚠ The generated code is the scan's code with the reflection taken out, and that is a decision about how the two tiers stay equal rather than a coincidence. Each declaration becomes the attribute itself, constructed with the arguments it was written with, handed to the same record constructor the scan calls with the same defaults; placement of menu lines is DeclaredMenus, which the scan calls too. What is left to disagree about is what each reader found, which DeclaredParityTests compares on one fixture.

⚠ Stricter than the scan, deliberately. The scan reads public members and passes silently over a private one carrying an attribute; the generated code can only reach what it can name, so a declaration it cannot reach is a compile error (VXP0002) rather than a line that quietly is not there.

⚠ Not packed into Vixen.Editor.Plugin's package, and that is the answer to #1283's "say which". A plugin off a disk is scanned after its Activate runs; if that Activate also called a generated Register, every declaration would be registered twice and the second command would throw. So an in-tree module gets this generator, an out-of-tree plugin gets the scan, and the two never meet. docs/GeneratorPackagingExempt.txt carries the line.

Methods (1)

  • public void Initialize(IncrementalGeneratorInitializationContext context)

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

Used by (3)

  • DeclaredParityTestsVixen.Editor.App.Tests
  • FindingVixen.Editor.Plugin.Generator
  • GeneratorHarnessVixen.Editor.Plugin.Generator.Tests