-
Notifications
You must be signed in to change notification settings - Fork 4
feat(config): 添加AI-First配置系统及源生成器 #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...SourceGenerators.Tests/Config/snapshots/SchemaConfigGenerator/MonsterConfigBindings.g.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| // <auto-generated /> | ||
| #nullable enable | ||
|
|
||
| namespace GFramework.Game.Config.Generated; | ||
|
|
||
| /// <summary> | ||
| /// Auto-generated registration and lookup helpers for schema file 'monster.schema.json'. | ||
| /// The helper centralizes table naming, config directory, schema path, and strong-typed registry access so consumer projects do not need to duplicate the same conventions. | ||
| /// </summary> | ||
| public static class MonsterConfigBindings | ||
| { | ||
| /// <summary> | ||
| /// Gets the runtime registration name of the generated config table. | ||
| /// </summary> | ||
| public const string TableName = "monster"; | ||
|
|
||
| /// <summary> | ||
| /// Gets the config directory path expected by the generated registration helper. | ||
| /// </summary> | ||
| public const string ConfigRelativePath = "monster"; | ||
|
|
||
| /// <summary> | ||
| /// Gets the schema file path expected by the generated registration helper. | ||
| /// </summary> | ||
| public const string SchemaRelativePath = "schemas/monster.schema.json"; | ||
|
|
||
| /// <summary> | ||
| /// Registers the generated config table using the schema-derived runtime conventions. | ||
| /// </summary> | ||
| /// <param name="loader">The target YAML config loader.</param> | ||
| /// <param name="comparer">Optional key comparer for the generated table registration.</param> | ||
| /// <returns>The same loader instance so registration can keep chaining.</returns> | ||
| public static global::GFramework.Game.Config.YamlConfigLoader RegisterMonsterTable( | ||
| this global::GFramework.Game.Config.YamlConfigLoader loader, | ||
| global::System.Collections.Generic.IEqualityComparer<int>? comparer = null) | ||
| { | ||
| if (loader is null) | ||
| { | ||
| throw new global::System.ArgumentNullException(nameof(loader)); | ||
| } | ||
|
|
||
| return loader.RegisterTable<int, MonsterConfig>( | ||
| TableName, | ||
| ConfigRelativePath, | ||
| SchemaRelativePath, | ||
| static config => config.Id, | ||
| comparer); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the generated config table wrapper from the registry. | ||
| /// </summary> | ||
| /// <param name="registry">The source config registry.</param> | ||
| /// <returns>The generated strong-typed table wrapper.</returns> | ||
| /// <exception cref="global::System.ArgumentNullException">When <paramref name="registry"/> is null.</exception> | ||
| 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<int, MonsterConfig>(TableName)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Tries to get the generated config table wrapper from the registry. | ||
| /// </summary> | ||
| /// <param name="registry">The source config registry.</param> | ||
| /// <param name="table">The generated strong-typed table wrapper when lookup succeeds; otherwise null.</param> | ||
| /// <returns>True when the generated table is registered and type-compatible; otherwise false.</returns> | ||
| /// <exception cref="global::System.ArgumentNullException">When <paramref name="registry"/> is null.</exception> | ||
| 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<int, MonsterConfig>(TableName, out var innerTable) && innerTable is not null) | ||
| { | ||
| table = new MonsterTable(innerTable); | ||
| return true; | ||
| } | ||
|
|
||
| table = null; | ||
| return false; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.