-
Notifications
You must be signed in to change notification settings - Fork 4
docs(config): 添加游戏内容配置系统完整文档 #209
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 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
40f5fd3
docs(config): 添加游戏内容配置系统完整文档
GeWuYou 0ea3c0a
refactor(config): 更新Godot YAML配置加载器的命名空间引用
GeWuYou 411d4cb
docs(config): 添加游戏内容配置系统完整文档
GeWuYou e746297
feat(config): 添加 Godot YAML 配置加载器支持
GeWuYou 1bf5d28
fix(config): 修复Godot YAML配置加载器的目录重置异常处理
GeWuYou 86ff046
docs(config): 更新 GodotYamlConfigLoader 异步加载方法的文档注释
GeWuYou 82091be
refactor(config): 更新Godot YAML配置加载器的文件访问引用
GeWuYou c29c9fe
feat(config): 添加配置表来源安全性验证功能
GeWuYou aedc30c
refactor(config): 更新Godot YAML配置加载器的文件访问引用
GeWuYou abf78aa
refactor(tests): 重构测试项目的全局引用配置
GeWuYou 1c064bf
fix(config): 解决目录列表加载错误问题
GeWuYou 0f13193
docs(config): 添加游戏内容配置系统完整文档
GeWuYou 8c8373d
refactor(config): 更新配置加载器依赖项
GeWuYou 35849f7
refactor(tests): 移除未使用的 Roslyn 分析器引用
GeWuYou 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
470 changes: 470 additions & 0 deletions
470
GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
Large diffs are not rendered by default.
Oops, something went wrong.
81 changes: 81 additions & 0 deletions
81
GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs
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,81 @@ | ||
| using System; | ||
| using GFramework.Godot.Config; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace GFramework.Godot.Tests.Config; | ||
|
|
||
| /// <summary> | ||
| /// 验证 Godot YAML 配置表来源描述会拒绝可能逃逸缓存根目录的不安全相对路径。 | ||
| /// </summary> | ||
| [TestFixture] | ||
| public sealed class GodotYamlConfigTableSourceTests | ||
| { | ||
| /// <summary> | ||
| /// 验证配置目录路径必须保持为无根、无遍历段的安全相对路径。 | ||
| /// </summary> | ||
| /// <param name="configRelativePath">待验证的配置目录路径。</param> | ||
| [TestCase("../outside")] | ||
| [TestCase(@"..\outside")] | ||
| [TestCase("./monster")] | ||
| [TestCase(@".\monster")] | ||
| [TestCase("monster/../outside")] | ||
| [TestCase(@"monster\..\outside")] | ||
| [TestCase("monster/./child")] | ||
| [TestCase(@"monster\.\child")] | ||
| [TestCase("/monster")] | ||
| [TestCase("C:/monster")] | ||
| [TestCase(@"C:\monster")] | ||
| [TestCase("res://monster")] | ||
| [TestCase("user://monster")] | ||
| public void Constructor_Should_Throw_When_Config_Relative_Path_Is_Not_Safe(string configRelativePath) | ||
| { | ||
| var exception = Assert.Throws<ArgumentException>(() => | ||
| _ = new GodotYamlConfigTableSource("monster", configRelativePath)); | ||
|
|
||
| Assert.That(exception!.ParamName, Is.EqualTo("configRelativePath")); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// 验证 schema 路径在提供时也必须满足同样的安全相对路径约束。 | ||
| /// </summary> | ||
| /// <param name="schemaRelativePath">待验证的 schema 路径。</param> | ||
| [TestCase("../schemas/monster.schema.json")] | ||
| [TestCase(@"..\schemas\monster.schema.json")] | ||
| [TestCase("./schemas/monster.schema.json")] | ||
| [TestCase(@".\schemas\monster.schema.json")] | ||
| [TestCase("schemas/../monster.schema.json")] | ||
| [TestCase(@"schemas\..\monster.schema.json")] | ||
| [TestCase("schemas/./monster.schema.json")] | ||
| [TestCase(@"schemas\.\monster.schema.json")] | ||
| [TestCase("/schemas/monster.schema.json")] | ||
| [TestCase("C:/schemas/monster.schema.json")] | ||
| [TestCase(@"C:\schemas\monster.schema.json")] | ||
| [TestCase("res://schemas/monster.schema.json")] | ||
| [TestCase("user://schemas/monster.schema.json")] | ||
| public void Constructor_Should_Throw_When_Schema_Relative_Path_Is_Not_Safe(string schemaRelativePath) | ||
| { | ||
| var exception = Assert.Throws<ArgumentException>(() => | ||
| _ = new GodotYamlConfigTableSource("monster", "monster", schemaRelativePath)); | ||
|
|
||
| Assert.That(exception!.ParamName, Is.EqualTo("schemaRelativePath")); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// 验证合法的相对目录和 schema 路径仍可正常构造元数据对象。 | ||
| /// </summary> | ||
| [Test] | ||
| public void Constructor_Should_Accept_Safe_Relative_Paths() | ||
| { | ||
| var source = new GodotYamlConfigTableSource( | ||
| "monster", | ||
| "monster/configs", | ||
| "schemas/monster.schema.json"); | ||
|
|
||
| Assert.Multiple(() => | ||
| { | ||
| Assert.That(source.TableName, Is.EqualTo("monster")); | ||
| Assert.That(source.ConfigRelativePath, Is.EqualTo("monster/configs")); | ||
| Assert.That(source.SchemaRelativePath, Is.EqualTo("schemas/monster.schema.json")); | ||
| }); | ||
| } | ||
| } | ||
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.