Class GeneratedSchemaRegistry
- Namespace
- Typhon.Schema.Definition
- Assembly
- Typhon.Schema.Definition.dll
Process-global sink for source-generated component schemas (feature #514). Each schema assembly's generated [ModuleInitializer] calls
RegisterComponent(Type, ComponentSchemaSpec) exactly once at assembly load; the engine reads specs via TryGetComponentSpec(Type, out ComponentSchemaSpec) when building component
definitions — so the schema build is reflection-free without the component implementing an interface (hence without the component needing to be partial).
public static class GeneratedSchemaRegistry
- Inheritance
-
GeneratedSchemaRegistry
- Inherited Members
Remarks
This lives in the schema-contract assembly — NOT the engine — so that schema-only assemblies (which reference only Typhon.Schema.Definition, never
Typhon.Engine) can still register their components from a generated module-init.
ALC-safe: backed by a ConditionalWeakTable<TKey, TValue> keyed weakly on the component Type, so a collectible AssemblyLoadContext is never pinned by this static — the entry is reclaimed together with the Type when the ALC unloads.
Methods
RegisterComponent(Type, ComponentSchemaSpec)
Registers a component's source-generated ComponentSchemaSpec, keyed by its CLR type. Called by generated module-initializers — not intended for hand-written code. Idempotent: a later identical registration overwrites with the same data.
public static void RegisterComponent(Type componentType, ComponentSchemaSpec spec)
Parameters
componentTypeTypeThe
[Component]struct type the spec describes.specComponentSchemaSpecThe component's schema shape (identity, storage/durability defaults, ordered fields).
TryGetComponentSpec(Type, out ComponentSchemaSpec)
Looks up a source-generated component spec by CLR type. Returns false when none is registered — the engine then falls back to runtime reflection (hand-authored components, or schema-only assemblies whose module-init did not run).
public static bool TryGetComponentSpec(Type componentType, out ComponentSchemaSpec spec)
Parameters
componentTypeTypeThe component struct type.
specComponentSchemaSpecThe registered spec, or
defaultwhen not found.
Returns
- bool
True if a spec was registered for the type.