// #nullable enable namespace GFramework.Game.Config.Generated; /// /// Auto-generated registration and lookup helpers for schema file 'monster.schema.json'. /// The helper centralizes table naming, config directory, schema path, and strongly-typed registry access so consumer projects do not need to duplicate the same conventions. /// public static class MonsterConfigBindings { /// /// Describes one schema property that declares x-gframework-ref-table metadata. /// public readonly struct ReferenceMetadata { /// /// Initializes one generated cross-table reference descriptor. /// /// Schema property path. /// Referenced runtime table name. /// Schema scalar type used by the reference value. /// Whether the property stores multiple reference keys. public ReferenceMetadata( string displayPath, string referencedTableName, string valueSchemaType, bool isCollection) { DisplayPath = displayPath ?? throw new global::System.ArgumentNullException(nameof(displayPath)); ReferencedTableName = referencedTableName ?? throw new global::System.ArgumentNullException(nameof(referencedTableName)); ValueSchemaType = valueSchemaType ?? throw new global::System.ArgumentNullException(nameof(valueSchemaType)); IsCollection = isCollection; } /// /// Gets the schema property path such as dropItems or phases[].monsterId. /// public string DisplayPath { get; } /// /// Gets the runtime registration name of the referenced config table. /// public string ReferencedTableName { get; } /// /// Gets the schema scalar type used by the referenced key value. /// public string ValueSchemaType { get; } /// /// Gets a value indicating whether the property stores multiple reference keys. /// public bool IsCollection { get; } } /// /// Groups the schema-derived metadata constants so consumer code can reuse one stable entry point. /// public static class Metadata { /// /// Gets the logical config domain derived from the schema base name. The current runtime convention keeps this value aligned with the generated table name. /// public const string ConfigDomain = "monster"; /// /// Gets the runtime registration name of the generated config table. /// public const string TableName = "monster"; /// /// Gets the config directory path expected by the generated registration helper. /// public const string ConfigRelativePath = "monster"; /// /// Gets the schema file path expected by the generated registration helper. /// public const string SchemaRelativePath = "schemas/monster.schema.json"; } /// /// Gets the logical config domain derived from the schema base name. The current runtime convention keeps this value aligned with the generated table name. /// public const string ConfigDomain = Metadata.ConfigDomain; /// /// Gets the runtime registration name of the generated config table. /// public const string TableName = Metadata.TableName; /// /// Gets the config directory path expected by the generated registration helper. /// public const string ConfigRelativePath = Metadata.ConfigRelativePath; /// /// Gets the schema file path expected by the generated registration helper. /// public const string SchemaRelativePath = Metadata.SchemaRelativePath; /// /// Serializes one generated config instance to YAML text using the shared runtime naming convention. /// /// The generated config instance to serialize. /// YAML text that preserves the shared camelCase field naming convention. /// Thrown when is . public static string SerializeToYaml(MonsterConfig config) { return global::GFramework.Game.Config.YamlConfigTextSerializer.Serialize(config); } /// /// Resolves the absolute config directory path by combining the caller-supplied config root with the generated relative directory. /// /// Absolute or workspace-local config root directory. /// The absolute config directory path for the generated table. /// Thrown when is null, empty, or whitespace. public static string GetConfigDirectoryPath(string configRootPath) { return GeneratedConfigCatalog.ResolveAbsolutePath(configRootPath, Metadata.ConfigRelativePath); } /// /// Resolves the absolute schema file path by combining the caller-supplied config root with the generated relative schema path. /// /// Absolute or workspace-local config root directory. /// The absolute schema file path for the generated table. /// Thrown when is null, empty, or whitespace. public static string GetSchemaPath(string configRootPath) { return GeneratedConfigCatalog.ResolveAbsolutePath(configRootPath, Metadata.SchemaRelativePath); } /// /// Validates YAML text against the generated schema file located under the supplied config root directory. /// /// Absolute or workspace-local config root directory. /// Logical or absolute YAML path used for diagnostics. /// YAML text to validate. /// Thrown when is null, empty, or whitespace. /// Thrown when or is . /// Thrown when the generated schema file cannot be loaded or the YAML text fails schema validation. public static void ValidateYaml(string configRootPath, string yamlPath, string yamlText) { global::GFramework.Game.Config.YamlConfigTextValidator.Validate( Metadata.TableName, GetSchemaPath(configRootPath), yamlPath, yamlText); } /// /// Asynchronously validates YAML text against the generated schema file located under the supplied config root directory. /// /// Absolute or workspace-local config root directory. /// Logical or absolute YAML path used for diagnostics. /// YAML text to validate. /// Cancellation token. /// A task that represents the asynchronous validation operation. /// Thrown when is null, empty, or whitespace. /// Thrown when or is . /// Thrown when the generated schema file cannot be loaded or the YAML text fails schema validation. public static global::System.Threading.Tasks.Task ValidateYamlAsync( string configRootPath, string yamlPath, string yamlText, global::System.Threading.CancellationToken cancellationToken = default) { return global::GFramework.Game.Config.YamlConfigTextValidator.ValidateAsync( Metadata.TableName, GetSchemaPath(configRootPath), yamlPath, yamlText, cancellationToken); } /// /// Exposes generated metadata for schema properties that declare x-gframework-ref-table. /// public static class References { /// /// Gets generated reference metadata for schema property path 'dropItems'. /// public static readonly ReferenceMetadata DropItems = new( "dropItems", "item", "string", true); /// /// Gets generated reference metadata for schema property path 'phases[].monsterId'. /// public static readonly ReferenceMetadata PhasesItemsMonsterId = new( "phases[].monsterId", "monster", "string", false); /// /// Gets all generated cross-table reference descriptors for the current schema. /// public static global::System.Collections.Generic.IReadOnlyList All { get; } = global::System.Array.AsReadOnly(new ReferenceMetadata[] { DropItems, PhasesItemsMonsterId, }); /// /// Tries to resolve generated reference metadata by schema property path. /// /// Schema property path. /// Resolved generated reference metadata when the path is known; otherwise the default value. /// True when the schema property path has generated cross-table metadata; otherwise false. public static bool TryGetByDisplayPath(string displayPath, out ReferenceMetadata metadata) { if (displayPath is null) { throw new global::System.ArgumentNullException(nameof(displayPath)); } if (string.Equals(displayPath, "dropItems", global::System.StringComparison.Ordinal)) { metadata = DropItems; return true; } if (string.Equals(displayPath, "phases[].monsterId", global::System.StringComparison.Ordinal)) { metadata = PhasesItemsMonsterId; return true; } metadata = default; return false; } } /// /// Registers the generated config table using the schema-derived runtime conventions. /// /// The target YAML config loader. /// Optional key comparer for the generated table registration. /// The same loader instance so registration can keep chaining. public static global::GFramework.Game.Config.YamlConfigLoader RegisterMonsterTable( this global::GFramework.Game.Config.YamlConfigLoader loader, global::System.Collections.Generic.IEqualityComparer? comparer = null) { if (loader is null) { throw new global::System.ArgumentNullException(nameof(loader)); } return loader.RegisterTable( Metadata.TableName, Metadata.ConfigRelativePath, Metadata.SchemaRelativePath, static config => config.Id, comparer); } /// /// Gets the generated config table wrapper from the registry. /// /// The source config registry. /// The generated strongly-typed table wrapper. /// When is null. public static MonsterTable GetMonsterTable(this global::GFramework.Game.Abstractions.Config.IConfigRegistry registry) { if (registry is null) { throw new global::System.ArgumentNullException(nameof(registry)); } return new MonsterTable(registry.GetTable(Metadata.TableName)); } /// /// Tries to get the generated config table wrapper from the registry. /// /// The source config registry. /// The generated strongly-typed table wrapper when lookup succeeds; otherwise null. /// True when the generated table is registered and type-compatible; otherwise false. /// When is null. public static bool TryGetMonsterTable(this global::GFramework.Game.Abstractions.Config.IConfigRegistry registry, out MonsterTable? table) { if (registry is null) { throw new global::System.ArgumentNullException(nameof(registry)); } if (registry.TryGetTable(Metadata.TableName, out var innerTable) && innerTable is not null) { table = new MonsterTable(innerTable); return true; } table = null; return false; } }