Class ClrSchemeTypeIndex
Process-global registry of schemeName → CLR Type, derived from .
This mapping is a database-independent fact: a type's scheme name comes from its attribute
and is identical regardless of which database/connection it is used against. Therefore it lives
once per process and is shared by every cache domain — unlike the per-domain
scheme_id → Type projection in , where scheme_id is a
per-database fact that must stay isolated per connection.
It is self-healing: assembly loads (including into plugin AssemblyLoadContexts) bump a
generation counter, and the index is rebuilt lazily on the next lookup. This removes the old
one-shot, per-domain snapshot that went stale whenever modules loaded after initialization.
Collectible ALC safety. Entries hold to , never
a strong reference. A strong Type keeps its AssemblyLoadContext alive, so a static index
that held one would pin every hot-reloaded plugin module in memory forever. Dead entries are pruned
lazily on lookup. See docs/CACHING_FIXES_PLAN.md (C1).
public static class ClrSchemeTypeIndex
Inheritance
Properties
Count
Diagnostics: number of live registered name keys (dead weak refs excluded).
public static int Count { get; }
Methods
Clear()
Test/reset hook — clears the index and forces a rescan on next lookup.
public static void Clear()
EnsureFresh()
Rescan loaded assemblies if any have loaded since the last scan. Cheap no-op when unchanged.
public static void EnsureFresh()
EnumerateSchemeTypes()
Single source of truth for assembly enumeration: broad (every load context), reflection-load-safe.
public static IEnumerable<Type> EnumerateSchemeTypes()
Register(string, Type)
Explicitly register a name → type mapping (e.g. from an authoritative scheme sync). Idempotent;
public static void Register(string schemeName, Type type)
Resolve(string)
Resolve a scheme name (or alias) to its CLR type, or null if no
public static Type? Resolve(string schemeName)
ThrowIfNameConflict(string, Type)
Throws when another distinct type has claimed the same explicit scheme name. Called from
public static void ThrowIfNameConflict(string schemeName, Type type)