Skip to content

docs(config): 添加游戏内容配置系统完整文档#209

Merged
GeWuYou merged 14 commits into
mainfrom
feat/game-content-config
Apr 11, 2026
Merged

docs(config): 添加游戏内容配置系统完整文档#209
GeWuYou merged 14 commits into
mainfrom
feat/game-content-config

Conversation

@GeWuYou

@GeWuYou GeWuYou commented Apr 10, 2026

Copy link
Copy Markdown
Owner
  • 新增面向静态游戏内容的 AI-First 配表方案介绍
  • 详细说明 YAML 作为配置源文件和 JSON Schema 结构描述功能
  • 提供推荐目录结构和 Schema 示例配置
  • 添加 VS Code 插件工具支持说明
  • 包含 Godot 文本配置桥接使用指南
  • 提供运行时读取和热重载模板示例
  • 说明生成器接入约定和运行时校验行为
  • 添加开发期热重载和工具支持详细说明
  • 创建 Godot 测试项目配置文件
  • 实现 GodotYamlConfigLoader 配置加载适配层

Summary by Sourcery

引入一个针对 Godot 的 YAML 配置加载桥接器,并在游戏配置系统中文档化其用法。

New Features:

  • 添加 GodotYamlConfigLoader,用于在使用 res://user:// 路径的 Godot 项目中适配基于 YAML 的游戏配置。
  • 引入 GodotYamlConfigLoaderOptionsGodotYamlConfigTableSource,用于配置 Godot YAML 表数据源以及运行时缓存行为。

Documentation:

  • 扩展游戏配置系统的中文文档,增加 Godot 文本配置桥接部分,并提供新加载器的示例使用代码。

Tests:

  • 添加集成测试,验证 GodotYamlConfigLoader 在编辑器和类导出环境中的行为,包括运行时缓存同步与热重载可用性。
Original summary in English

Summary by Sourcery

Introduce a Godot-specific YAML configuration loading bridge and document its usage within the game config system.

New Features:

  • Add GodotYamlConfigLoader to adapt YAML-based game configs for Godot projects using res:// and user:// paths.
  • Introduce GodotYamlConfigLoaderOptions and GodotYamlConfigTableSource to configure Godot YAML table sources and runtime cache behavior.

Documentation:

  • Extend the Chinese game config system documentation with a Godot text config bridge section and example usage code for the new loader.

Tests:

  • Add integration-style tests validating GodotYamlConfigLoader behavior in editor and exported-like environments, including runtime cache synchronization and hot-reload availability.

Summary by CodeRabbit

  • 新增功能
    • 新增 Godot YAML 配置加载器、对应选项与表源类,支持编辑器/导出两种路径处理、运行时缓存同步与按条件启用热重载
  • 测试
    • 新增加载器与表源单元测试,覆盖编辑器模式、导出缓存行为、父子目录同步、路径校验、损坏元数据与错误包装场景
  • 文档
    • 补充中文文档,说明路径安全约束、编辑器/导出差异与示例用法
  • 杂项
    • 更新测试项目引用并开放程序集以支持新增测试

- 新增面向静态游戏内容的 AI-First 配表方案介绍
- 详细说明 YAML 作为配置源文件和 JSON Schema 结构描述功能
- 提供推荐目录结构和 Schema 示例配置
- 添加 VS Code 插件工具支持说明
- 包含 Godot 文本配置桥接使用指南
- 提供运行时读取和热重载模板示例
- 说明生成器接入约定和运行时校验行为
- 添加开发期热重载和工具支持详细说明
- 创建 Godot 测试项目配置文件
- 实现 GodotYamlConfigLoader 配置加载适配层
@coderabbitai

coderabbitai Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

新增 Godot 专用 YAML 配置加载器、选项与表源类型,加入 Godot 路径环境抽象;在导出模式下将已注册 YAML/schema 同步到 user:// 运行时缓存,区分编辑器/导出行为并控制热重载可用性;附带单元测试与文档更新。

Changes

Cohort / File(s) Summary
Godot YAML 配置加载器核心实现
GFramework.Godot/Config/GodotYamlConfigLoader.cs, GFramework.Godot/Config/GodotYamlConfigLoaderOptions.cs, GFramework.Godot/Config/GodotYamlConfigTableSource.cs
新增密封类 GodotYamlConfigLoader(实现 IConfigLoader)及其选项与表源类型;引入 GodotYamlConfigEnvironment 抽象、路径安全检查、导出模式下的 runtime-cache 同步逻辑、错误封装为 ConfigLoadException,并由可访问性决定 CanEnableHotReload/EnableHotReload 行为。
测试 与 测试项目配置
GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs, GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs, GFramework.Godot.Tests/GFramework.Godot.Tests.csproj, GFramework.Godot/Properties/AssemblyInfo.cs
新增 loader 端到端临时目录测试与表源路径验证测试;测试项目添加对 GFramework.Game.AbstractionsGFramework.Core.Abstractions 的引用;添加 InternalsVisibleTo("GFramework.Godot.Tests")
文档
docs/zh-CN/game/config-system.md
文档新增“Godot 文本配置桥接”节,说明编辑器/导出路径差异、示例用法及限制(导出需包含文本资产,热重载仅在可直接访问源时可用);并更新相对路径约束(禁止 ... 及绝对路径)。

Sequence Diagram

sequenceDiagram
    actor Caller
    participant Loader as GodotYamlConfigLoader
    participant Env as GodotYamlConfigEnvironment
    participant FS as Filesystem/Cache
    participant YamlLoader as YamlConfigLoader
    participant Registry as IConfigRegistry

    Caller->>Loader: LoadAsync(registry, cancellation)
    Loader->>Env: Globalize & 检查 SourceRootPath 可访问性
    Env-->>Loader: 返回(是否可直接访问, 全局路径?)

    alt 不可直接访问(导出/需缓存)
        Loader->>FS: 枚举 TableSource 目录与 schema 文件
        FS-->>Loader: 目录条目与文件内容
        Loader->>FS: 重置/创建 runtime cache 并写入已注册 YAML/schema
        FS-->>Loader: 写入完成
        Loader->>YamlLoader: 指向 runtime cache 的 LoaderRootPath 并 调用 LoadAsync
    else 可直接访问(编辑器)
        Loader->>YamlLoader: 使用全局化的 res:// 路径 直接 LoadAsync
    end

    YamlLoader->>Registry: 解析并注册配置
    Registry-->>YamlLoader: 注册完成
    YamlLoader-->>Loader: 返回加载结果
    Loader-->>Caller: 完成
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning PR 标题为"docs(config): 添加游戏内容配置系统完整文档",但实际变更不仅包含文档,还包括新增的生产代码实现(GodotYamlConfigLoader、GodotYamlConfigLoaderOptions、GodotYamlConfigTableSource)以及相应的单元/集成测试,代码行数超过1000行。标题仅聚焦于"文档",误导性地忽视了主要的功能实现部分。 建议修改 PR 标题为"feat(config): 添加 Godot YAML 配置加载器与文档"或类似表述,以准确反映本 PR 既包含新功能实现又包含文档的实际范围。
Docstring Coverage ⚠️ Warning Docstring coverage is 56.52% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/game-content-config

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai

sourcery-ai Bot commented Apr 10, 2026

Copy link
Copy Markdown

审阅者指南

为基于 YAML 的游戏配置系统补充了完整文档,并新增一个具体的 Godot 集成层:包括带 res:// / user:// 处理的 Godot 专用加载器、相关选项和表源模型类型,以及验证编辑器与导出行为、热重载约束的测试。

编辑器模式 vs 导出模式下 GodotYamlConfigLoader.LoadAsync 的时序图

sequenceDiagram
    actor GameCode
    participant GodotYamlConfigLoader as GodotYamlConfigLoader
    participant GodotYamlConfigEnvironment as Environment
    participant YamlConfigLoader as YamlConfigLoader

    GameCode->>GodotYamlConfigLoader: new GodotYamlConfigLoader(options)
    activate GodotYamlConfigLoader
    GodotYamlConfigLoader->>GodotYamlConfigLoader: ResolveLoaderRootPath()
    alt SourceRootPath is Godot path
        GodotYamlConfigLoader->>Environment: IsEditor()
        alt Running_in_editor
            GodotYamlConfigLoader->>Environment: GlobalizePath(SourceRootPath)
            GodotYamlConfigLoader-->>GodotYamlConfigLoader: LoaderRootPath = globalized_res
        else Exported_build
            GodotYamlConfigLoader->>Environment: GlobalizePath(RuntimeCacheRootPath)
            GodotYamlConfigLoader-->>GodotYamlConfigLoader: LoaderRootPath = globalized_user_cache
        end
    else SourceRootPath is normal or user path
        GodotYamlConfigLoader-->>GodotYamlConfigLoader: LoaderRootPath = full_path(SourceRootPath)
    end
    GodotYamlConfigLoader->>GodotYamlConfigLoader: _loader = new YamlConfigLoader(LoaderRootPath)
    GodotYamlConfigLoader->>GodotYamlConfigLoader: options.ConfigureLoader(_loader)
    deactivate GodotYamlConfigLoader

    GameCode->>GodotYamlConfigLoader: LoadAsync(registry)
    activate GodotYamlConfigLoader
    alt CanEnableHotReload == false
        GodotYamlConfigLoader->>GodotYamlConfigLoader: SynchronizeRuntimeCache()
        loop For each config path group
            GodotYamlConfigLoader->>Environment: EnumerateDirectory(res_config_dir)
            alt Directory_not_found
                GodotYamlConfigLoader-->>GameCode: throw ConfigLoadException
            else Directory_found
                loop For each yaml file
                    GodotYamlConfigLoader->>Environment: FileExists(filePath)
                    alt Missing_or_read_error
                        GodotYamlConfigLoader-->>GameCode: throw ConfigLoadException
                    else OK
                        GodotYamlConfigLoader->>Environment: ReadAllBytes(filePath)
                        GodotYamlConfigLoader->>FileSystem: WriteAllBytes(cacheFilePath)
                    end
                end
            end
        end
        note over GodotYamlConfigLoader,YamlConfigLoader: LoaderRootPath points to user:// runtime cache
    else CanEnableHotReload == true
        note over GodotYamlConfigLoader,YamlConfigLoader: LoaderRootPath points to project directory
    end

    GodotYamlConfigLoader->>YamlConfigLoader: LoadAsync(registry)
    YamlConfigLoader-->>GodotYamlConfigLoader: Completed
    GodotYamlConfigLoader-->>GameCode: Completed
    deactivate GodotYamlConfigLoader

    GameCode->>GodotYamlConfigLoader: EnableHotReload(registry)
    alt CanEnableHotReload == false
        GodotYamlConfigLoader-->>GameCode: throw InvalidOperationException
    else CanEnableHotReload == true
        GodotYamlConfigLoader->>YamlConfigLoader: EnableHotReload(registry, options)
        YamlConfigLoader-->>GodotYamlConfigLoader: IUnRegister
        GodotYamlConfigLoader-->>GameCode: IUnRegister
    end
Loading

新 Godot YAML 配置加载器集成的类图

classDiagram
    direction LR

    class IConfigLoader {
        <<interface>>
        +LoadAsync(registry IConfigRegistry, cancellationToken CancellationToken) Task
    }

    class IConfigRegistry {
        <<interface>>
    }

    class IUnRegister {
        <<interface>>
    }

    class YamlConfigLoader {
        +YamlConfigLoader(rootPath string)
        +LoadAsync(registry IConfigRegistry, cancellationToken CancellationToken) Task
        +EnableHotReload(registry IConfigRegistry, options YamlConfigHotReloadOptions) IUnRegister
    }

    class YamlConfigHotReloadOptions

    class ConfigLoadException
    class ConfigLoadDiagnostic
    class ConfigLoadFailureKind

    class GodotYamlConfigLoaderOptions {
        +SourceRootPath string
        +RuntimeCacheRootPath string
        +TableSources IReadOnlyCollection~GodotYamlConfigTableSource~
        +ConfigureLoader Action~YamlConfigLoader~
    }

    class GodotYamlConfigTableSource {
        +GodotYamlConfigTableSource(tableName string, configRelativePath string, schemaRelativePath string)
        +TableName string
        +ConfigRelativePath string
        +SchemaRelativePath string
    }

    class GodotYamlConfigLoader {
        -_environment GodotYamlConfigEnvironment
        -_loader YamlConfigLoader
        -_options GodotYamlConfigLoaderOptions
        +GodotYamlConfigLoader(options GodotYamlConfigLoaderOptions)
        +GodotYamlConfigLoader(options GodotYamlConfigLoaderOptions, environment GodotYamlConfigEnvironment)
        +SourceRootPath string
        +RuntimeCacheRootPath string
        +LoaderRootPath string
        +Loader YamlConfigLoader
        +CanEnableHotReload bool
        +LoadAsync(registry IConfigRegistry, cancellationToken CancellationToken) Task
        +EnableHotReload(registry IConfigRegistry, options YamlConfigHotReloadOptions) IUnRegister
        -ResolveLoaderRootPath() string
        -UsesSourceDirectoryDirectly(sourceRootPath string) bool
        -SynchronizeRuntimeCache(cancellationToken CancellationToken) void
        -CopyYamlFilesInDirectory(tableName string, sourceDirectoryPath string, targetDirectoryPath string, cancellationToken CancellationToken) void
        -CopySingleFile(tableName string, sourceFilePath string, targetAbsolutePath string, missingFailureKind ConfigLoadFailureKind, readFailureKind ConfigLoadFailureKind, configDirectoryPath string, yamlPath string) void
        -ResetDirectory(directoryPath string) void
        -EnsureAbsolutePath(path string, optionName string) string
        -DescribePath(path string) string
        -CombinePath(rootPath string, relativePath string) string
        -CombineAbsolutePath(rootPath string, relativePath string) string
        -NormalizeRelativePath(relativePath string) string
        -IsYamlFile(fileName string) bool
        -CreateConfigLoadException(failureKind ConfigLoadFailureKind, tableName string, message string, configDirectoryPath string, yamlPath string, schemaPath string, innerException Exception) ConfigLoadException
    }

    class GodotYamlConfigEnvironment {
        +GodotYamlConfigEnvironment(isEditor Func~bool~, globalizePath Func~string,string~, enumerateDirectory Func~string,IReadOnlyList~GodotYamlConfigDirectoryEntry~~, fileExists Func~string,bool~, readAllBytes Func~string,byte[]~)
        +IsEditor Func~bool~
        +GlobalizePath Func~string,string~
        +EnumerateDirectory Func~string,IReadOnlyList~GodotYamlConfigDirectoryEntry~?~
        +FileExists Func~string,bool~
        +ReadAllBytes Func~string,byte[]~
        +Default GodotYamlConfigEnvironment
        -EnumerateDirectoryCore(path string) IReadOnlyList~GodotYamlConfigDirectoryEntry~?
        -FileExistsCore(path string) bool
        -ReadAllBytesCore(path string) byte[]
    }

    class GodotYamlConfigDirectoryEntry {
        +Name string
        +IsDirectory bool
    }

    GodotYamlConfigLoader ..|> IConfigLoader
    GodotYamlConfigLoader o--> GodotYamlConfigLoaderOptions
    GodotYamlConfigLoader o--> GodotYamlConfigEnvironment
    GodotYamlConfigLoader o--> YamlConfigLoader
    GodotYamlConfigLoaderOptions "1" o--> "*" GodotYamlConfigTableSource
    GodotYamlConfigEnvironment --> GodotYamlConfigDirectoryEntry
    YamlConfigLoader ..> IConfigLoader
    YamlConfigLoader ..> YamlConfigHotReloadOptions
    YamlConfigLoader ..> IConfigRegistry
    GodotYamlConfigLoader ..> IConfigRegistry
    GodotYamlConfigLoader ..> IUnRegister
    GodotYamlConfigLoader ..> ConfigLoadException
    GodotYamlConfigLoader ..> ConfigLoadDiagnostic
    GodotYamlConfigLoader ..> ConfigLoadFailureKind
    GodotYamlConfigLoader ..> GodotYamlConfigDirectoryEntry
Loading

文件级变更

变更 详情 文件
使用 Godot 文本配置桥接部分和使用示例扩展配置系统文档。
  • 说明为什么应优先使用 GodotYamlConfigLoader,而不是自定义的 res:// + user:// 桥接代码。
  • 解释编辑器模式与导出模式下的行为,以及源码路径和缓存路径是如何处理的。
  • 提供一个 C# 使用示例,展示如何与 GeneratedConfigCatalog、GodotYamlConfigLoaderOptions 集成,以及热重载的约束。
  • 记录导出时资产打包要求,以及在使用 user:// 缓存时对热重载的限制。
docs/zh-CN/game/config-system.md
引入 GodotYamlConfigLoader,作为基于 YamlConfigLoader 的 Godot 专用适配器,提供对 res:// 和 user:// 的支持。
  • 从选项中验证并存储 SourceRootPath 和 RuntimeCacheRootPath,并根据运行环境和路径类型解析 LoaderRootPath。
  • 公开 LoaderRootPath、SourceRootPath、RuntimeCacheRootPath、底层的 YamlConfigLoader,以及一个 CanEnableHotReload 标志。
  • 实现 LoadAsync:当无法直接访问源码目录时,可选地将声明的表源从 SourceRootPath 同步到运行时缓存,然后再委托给 YamlConfigLoader。
  • 实现 EnableHotReload:当加载器基于运行时缓存而不是实际源码目录工作时,阻止热重载的使用。
  • 提供用于 Godot 路径规范化、路径合并、检查 YAML 文件,以及为缺失或不可读的配置/Schema 文件创建包含丰富信息的 ConfigLoadException 的辅助方法。
GFramework.Godot/Config/GodotYamlConfigLoader.cs
添加供加载器使用的 Godot 专用环境抽象,用于文件系统和 Godot API 访问。
  • 定义 GodotYamlConfigEnvironment,其中包含 IsEditor、GlobalizePath、目录枚举、文件存在性检查和读取文件字节的委托。
  • 提供一个 Default 实现,根据路径是否为 Godot 路径,接好 OS.HasFeature、ProjectSettings.GlobalizePath、DirAccess、FileAccess 和 System.IO API。
  • 引入 GodotYamlConfigDirectoryEntry 以表示目录枚举结果中的条目。
GFramework.Godot/Config/GodotYamlConfigLoader.cs
为配置 GodotYamlConfigLoader 添加选项和表源模型类型。
  • 引入 GodotYamlConfigTableSource,用于描述单个配置表的名称、YAML 目录路径和可选的 Schema 路径,并在构造函数中进行参数校验。
  • 引入 GodotYamlConfigLoaderOptions,用于配置源码根目录、运行时缓存根目录、表源集合,以及一个在底层 YamlConfigLoader 上注册表的 ConfigureLoader 回调。
  • 为 SourceRootPath(默认为 res://)和 RuntimeCacheRootPath(默认为 user://config_cache)设置合理的默认值。
GFramework.Godot/Config/GodotYamlConfigTableSource.cs
GFramework.Godot/Config/GodotYamlConfigLoaderOptions.cs
为 GodotYamlConfigLoader 的行为添加测试,并将内部实现暴露给测试程序集。
  • 创建 GodotYamlConfigLoaderTests,通过自定义的 GodotYamlConfigEnvironment 将 res:// 和 user:// 映射到临时目录。
  • 测试导出模式行为:只将声明的 YAML 和 Schema 资产复制到运行时缓存中,并将其作为 LoaderRootPath,同时禁止热重载。
  • 测试编辑器模式行为:直接使用全局化后的资源目录作为 LoaderRootPath,启用热重载,并且不填充运行时缓存。
  • 验证在针对运行时缓存而非真实源码目录操作时调用 EnableHotReload 会抛出异常。
  • 定义一个精简的 MonsterConfigStub 以及辅助方法,用于生成配置/Schema 测试数据,并将 Godot 风格路径映射到临时文件夹。
  • 声明 InternalsVisibleTo("GFramework.Godot.Tests"),使测试可以访问 GodotYamlConfigEnvironment 等内部类型。
GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
GFramework.Godot/Properties/AssemblyInfo.cs
GFramework.Godot.Tests/GFramework.Godot.Tests.csproj

技巧与命令

与 Sourcery 交互

  • 触发新评审: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的评审评论。
  • 从评审评论生成 GitHub issue: 在评审评论下回复,请求 Sourcery 从该评论创建 issue。也可以直接回复 @sourcery-ai issue 来从该评论创建 issue。
  • 生成 pull request 标题: 在 PR 标题的任意位置写入 @sourcery-ai,即可随时生成标题。也可以在 PR 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 pull request 摘要: 在 PR 正文任意位置写入 @sourcery-ai summary,即可在该位置生成 PR 摘要。也可以在 PR 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审阅者指南: 在 pull request 中评论 @sourcery-ai guide,即可(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 撤销所有 Sourcery 评审: 在 pull request 中评论 @sourcery-ai dismiss,即可撤销所有已有的 Sourcery 评审。若你希望从一次全新的评审开始,尤其有用——别忘了随后评论 @sourcery-ai review 来触发新的评审!

自定义你的使用体验

进入你的 控制面板 以:

  • 启用或关闭 Sourcery 生成的 PR 摘要、审阅者指南等评审功能。
  • 修改评审语言。
  • 增加、删除或编辑自定义评审指令。
  • 调整其他评审设置。

获取帮助

Original review guide in English

Reviewer's Guide

Adds full documentation and a concrete Godot integration layer for the YAML-based game config system, including a Godot-specific loader with res:// / user:// handling, associated options and table-source model types, plus tests validating editor vs export behavior and hot-reload constraints.

Sequence diagram for GodotYamlConfigLoader.LoadAsync in editor vs export

sequenceDiagram
    actor GameCode
    participant GodotYamlConfigLoader as GodotYamlConfigLoader
    participant GodotYamlConfigEnvironment as Environment
    participant YamlConfigLoader as YamlConfigLoader

    GameCode->>GodotYamlConfigLoader: new GodotYamlConfigLoader(options)
    activate GodotYamlConfigLoader
    GodotYamlConfigLoader->>GodotYamlConfigLoader: ResolveLoaderRootPath()
    alt SourceRootPath is Godot path
        GodotYamlConfigLoader->>Environment: IsEditor()
        alt Running_in_editor
            GodotYamlConfigLoader->>Environment: GlobalizePath(SourceRootPath)
            GodotYamlConfigLoader-->>GodotYamlConfigLoader: LoaderRootPath = globalized_res
        else Exported_build
            GodotYamlConfigLoader->>Environment: GlobalizePath(RuntimeCacheRootPath)
            GodotYamlConfigLoader-->>GodotYamlConfigLoader: LoaderRootPath = globalized_user_cache
        end
    else SourceRootPath is normal or user path
        GodotYamlConfigLoader-->>GodotYamlConfigLoader: LoaderRootPath = full_path(SourceRootPath)
    end
    GodotYamlConfigLoader->>GodotYamlConfigLoader: _loader = new YamlConfigLoader(LoaderRootPath)
    GodotYamlConfigLoader->>GodotYamlConfigLoader: options.ConfigureLoader(_loader)
    deactivate GodotYamlConfigLoader

    GameCode->>GodotYamlConfigLoader: LoadAsync(registry)
    activate GodotYamlConfigLoader
    alt CanEnableHotReload == false
        GodotYamlConfigLoader->>GodotYamlConfigLoader: SynchronizeRuntimeCache()
        loop For each config path group
            GodotYamlConfigLoader->>Environment: EnumerateDirectory(res_config_dir)
            alt Directory_not_found
                GodotYamlConfigLoader-->>GameCode: throw ConfigLoadException
            else Directory_found
                loop For each yaml file
                    GodotYamlConfigLoader->>Environment: FileExists(filePath)
                    alt Missing_or_read_error
                        GodotYamlConfigLoader-->>GameCode: throw ConfigLoadException
                    else OK
                        GodotYamlConfigLoader->>Environment: ReadAllBytes(filePath)
                        GodotYamlConfigLoader->>FileSystem: WriteAllBytes(cacheFilePath)
                    end
                end
            end
        end
        note over GodotYamlConfigLoader,YamlConfigLoader: LoaderRootPath points to user:// runtime cache
    else CanEnableHotReload == true
        note over GodotYamlConfigLoader,YamlConfigLoader: LoaderRootPath points to project directory
    end

    GodotYamlConfigLoader->>YamlConfigLoader: LoadAsync(registry)
    YamlConfigLoader-->>GodotYamlConfigLoader: Completed
    GodotYamlConfigLoader-->>GameCode: Completed
    deactivate GodotYamlConfigLoader

    GameCode->>GodotYamlConfigLoader: EnableHotReload(registry)
    alt CanEnableHotReload == false
        GodotYamlConfigLoader-->>GameCode: throw InvalidOperationException
    else CanEnableHotReload == true
        GodotYamlConfigLoader->>YamlConfigLoader: EnableHotReload(registry, options)
        YamlConfigLoader-->>GodotYamlConfigLoader: IUnRegister
        GodotYamlConfigLoader-->>GameCode: IUnRegister
    end
Loading

Class diagram for new Godot YAML config loader integration

classDiagram
    direction LR

    class IConfigLoader {
        <<interface>>
        +LoadAsync(registry IConfigRegistry, cancellationToken CancellationToken) Task
    }

    class IConfigRegistry {
        <<interface>>
    }

    class IUnRegister {
        <<interface>>
    }

    class YamlConfigLoader {
        +YamlConfigLoader(rootPath string)
        +LoadAsync(registry IConfigRegistry, cancellationToken CancellationToken) Task
        +EnableHotReload(registry IConfigRegistry, options YamlConfigHotReloadOptions) IUnRegister
    }

    class YamlConfigHotReloadOptions

    class ConfigLoadException
    class ConfigLoadDiagnostic
    class ConfigLoadFailureKind

    class GodotYamlConfigLoaderOptions {
        +SourceRootPath string
        +RuntimeCacheRootPath string
        +TableSources IReadOnlyCollection~GodotYamlConfigTableSource~
        +ConfigureLoader Action~YamlConfigLoader~
    }

    class GodotYamlConfigTableSource {
        +GodotYamlConfigTableSource(tableName string, configRelativePath string, schemaRelativePath string)
        +TableName string
        +ConfigRelativePath string
        +SchemaRelativePath string
    }

    class GodotYamlConfigLoader {
        -_environment GodotYamlConfigEnvironment
        -_loader YamlConfigLoader
        -_options GodotYamlConfigLoaderOptions
        +GodotYamlConfigLoader(options GodotYamlConfigLoaderOptions)
        +GodotYamlConfigLoader(options GodotYamlConfigLoaderOptions, environment GodotYamlConfigEnvironment)
        +SourceRootPath string
        +RuntimeCacheRootPath string
        +LoaderRootPath string
        +Loader YamlConfigLoader
        +CanEnableHotReload bool
        +LoadAsync(registry IConfigRegistry, cancellationToken CancellationToken) Task
        +EnableHotReload(registry IConfigRegistry, options YamlConfigHotReloadOptions) IUnRegister
        -ResolveLoaderRootPath() string
        -UsesSourceDirectoryDirectly(sourceRootPath string) bool
        -SynchronizeRuntimeCache(cancellationToken CancellationToken) void
        -CopyYamlFilesInDirectory(tableName string, sourceDirectoryPath string, targetDirectoryPath string, cancellationToken CancellationToken) void
        -CopySingleFile(tableName string, sourceFilePath string, targetAbsolutePath string, missingFailureKind ConfigLoadFailureKind, readFailureKind ConfigLoadFailureKind, configDirectoryPath string, yamlPath string) void
        -ResetDirectory(directoryPath string) void
        -EnsureAbsolutePath(path string, optionName string) string
        -DescribePath(path string) string
        -CombinePath(rootPath string, relativePath string) string
        -CombineAbsolutePath(rootPath string, relativePath string) string
        -NormalizeRelativePath(relativePath string) string
        -IsYamlFile(fileName string) bool
        -CreateConfigLoadException(failureKind ConfigLoadFailureKind, tableName string, message string, configDirectoryPath string, yamlPath string, schemaPath string, innerException Exception) ConfigLoadException
    }

    class GodotYamlConfigEnvironment {
        +GodotYamlConfigEnvironment(isEditor Func~bool~, globalizePath Func~string,string~, enumerateDirectory Func~string,IReadOnlyList~GodotYamlConfigDirectoryEntry~~, fileExists Func~string,bool~, readAllBytes Func~string,byte[]~)
        +IsEditor Func~bool~
        +GlobalizePath Func~string,string~
        +EnumerateDirectory Func~string,IReadOnlyList~GodotYamlConfigDirectoryEntry~?~
        +FileExists Func~string,bool~
        +ReadAllBytes Func~string,byte[]~
        +Default GodotYamlConfigEnvironment
        -EnumerateDirectoryCore(path string) IReadOnlyList~GodotYamlConfigDirectoryEntry~?
        -FileExistsCore(path string) bool
        -ReadAllBytesCore(path string) byte[]
    }

    class GodotYamlConfigDirectoryEntry {
        +Name string
        +IsDirectory bool
    }

    GodotYamlConfigLoader ..|> IConfigLoader
    GodotYamlConfigLoader o--> GodotYamlConfigLoaderOptions
    GodotYamlConfigLoader o--> GodotYamlConfigEnvironment
    GodotYamlConfigLoader o--> YamlConfigLoader
    GodotYamlConfigLoaderOptions "1" o--> "*" GodotYamlConfigTableSource
    GodotYamlConfigEnvironment --> GodotYamlConfigDirectoryEntry
    YamlConfigLoader ..> IConfigLoader
    YamlConfigLoader ..> YamlConfigHotReloadOptions
    YamlConfigLoader ..> IConfigRegistry
    GodotYamlConfigLoader ..> IConfigRegistry
    GodotYamlConfigLoader ..> IUnRegister
    GodotYamlConfigLoader ..> ConfigLoadException
    GodotYamlConfigLoader ..> ConfigLoadDiagnostic
    GodotYamlConfigLoader ..> ConfigLoadFailureKind
    GodotYamlConfigLoader ..> GodotYamlConfigDirectoryEntry
Loading

File-Level Changes

Change Details Files
Extend config system docs with a Godot text-config bridge section and usage example.
  • Describe why to prefer GodotYamlConfigLoader over custom res:// + user:// bridge code.
  • Explain editor vs export behavior and how source and cache paths are handled.
  • Provide a C# usage snippet showing integration with GeneratedConfigCatalog, GodotYamlConfigLoaderOptions, and hot-reload constraints.
  • Document export-time asset inclusion requirements and limitations on hot reload when using user:// caches.
docs/zh-CN/game/config-system.md
Introduce GodotYamlConfigLoader as a Godot-specific adapter over YamlConfigLoader with res:// and user:// support.
  • Validate and store SourceRootPath and RuntimeCacheRootPath from options and resolve LoaderRootPath based on environment and path type.
  • Expose LoaderRootPath, SourceRootPath, RuntimeCacheRootPath, underlying YamlConfigLoader, and a CanEnableHotReload flag.
  • Implement LoadAsync to optionally synchronize declared table sources from SourceRootPath into a runtime cache when direct source access is not possible, then delegate to YamlConfigLoader.
  • Implement EnableHotReload to guard against use when the loader is operating on a runtime cache instead of the real source directory.
  • Provide helpers for Godot path normalization, combining paths, checking for YAML files, and creating rich ConfigLoadException instances for missing or unreadable config/schema files.
GFramework.Godot/Config/GodotYamlConfigLoader.cs
Add a Godot-specific environment abstraction used by the loader for filesystem and Godot API access.
  • Define GodotYamlConfigEnvironment with delegates for IsEditor, GlobalizePath, directory enumeration, file existence checks, and reading file bytes.
  • Provide a Default implementation wiring to OS.HasFeature, ProjectSettings.GlobalizePath, DirAccess, FileAccess, and System.IO APIs depending on whether a path is a Godot path.
  • Introduce GodotYamlConfigDirectoryEntry to represent directory entries for enumeration.
GFramework.Godot/Config/GodotYamlConfigLoader.cs
Add option and table-source model types for configuring GodotYamlConfigLoader.
  • Introduce GodotYamlConfigTableSource to describe a single config table’s name, YAML directory path, and optional schema path, with argument validation in the constructor.
  • Introduce GodotYamlConfigLoaderOptions to configure source and runtime cache roots, the set of table sources, and a ConfigureLoader callback that registers tables on the underlying YamlConfigLoader.
  • Set sensible defaults for SourceRootPath (res://) and RuntimeCacheRootPath (user://config_cache).
GFramework.Godot/Config/GodotYamlConfigTableSource.cs
GFramework.Godot/Config/GodotYamlConfigLoaderOptions.cs
Add tests for GodotYamlConfigLoader behavior and expose internals to the test assembly.
  • Create GodotYamlConfigLoaderTests that map res:// and user:// into temporary directories via a custom GodotYamlConfigEnvironment.
  • Test export-mode behavior: copying only declared YAML and schema assets into the runtime cache and using that as LoaderRootPath, while disallowing hot reload.
  • Test editor-mode behavior: directly using the globalized resource directory as LoaderRootPath, enabling hot reload, and not populating the runtime cache.
  • Verify EnableHotReload throws when operating against a runtime cache rather than the real source directory.
  • Define a minimal MonsterConfigStub and helper methods to generate config/schema test data and map Godot-style paths to temp folders.
  • Declare InternalsVisibleTo("GFramework.Godot.Tests") so tests can access internal types like GodotYamlConfigEnvironment.
GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
GFramework.Godot/Properties/AssemblyInfo.cs
GFramework.Godot.Tests/GFramework.Godot.Tests.csproj

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我已经审查了你的更改,看起来很棒!


Sourcery 对开源项目是免费的——如果你喜欢我们的审查,请考虑分享它们 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进之后的审查。
Original comment in English

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

- 为Godot.FileAccess添加using别名以避免冲突
- 添加GFramework.Game.Config命名空间引用
- 添加NUnit.Framework测试框架引用
- 优化配置加载器的依赖管理
- 提升代码可读性和维护性
- 确保测试类的正确引用关系
@GeWuYou

GeWuYou commented Apr 10, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai help

@coderabbitai

coderabbitai Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/zh-CN/game/config-system.md`:
- Around line 316-317: 将“导出态:把当前注册会访问到的配置目录与 schema 文件同步到 `user://` 缓存,再交给底层
`YamlConfigLoader`”这句改为更顺畅的被动/说明式表述,例如“导出态:会将当前注册会访问到的配置目录与 schema 文件同步到
`user://` 缓存,再交给底层 `YamlConfigLoader`”,以避免读者误解动作主语;请在
docs/zh-CN/game/config-system.md 中定位包含该原句的段落并替换为建议表述(保留后半句 “再交给底层
`YamlConfigLoader`” 不变)。

In `@GFramework.Godot/Config/GodotYamlConfigLoader.cs`:
- Around line 29-31: Add XML documentation to the internal constructor
GodotYamlConfigLoader(GodotYamlConfigLoaderOptions, GodotYamlConfigEnvironment)
and to the GodotYamlConfigEnvironment and GodotYamlConfigDirectoryEntry types:
include <summary> describing why this internal abstraction exists (editor vs
export compatibility), <param> for each delegate explaining input constraints
(e.g., accepted path formats), when a delegate may legitimately return null,
<returns> conventions, <exception> cases for failure behavior, and a <remarks>
note clarifying the differences between Godot-style paths and filesystem paths
and any normalization rules; apply the same XML doc requirements to the related
members covered by the same abstraction (the other internal/public members that
implement these delegates) so all contracts around inputs, outputs, nullability,
and error handling are explicitly documented.

In `@GFramework.Godot/Config/GodotYamlConfigTableSource.cs`:
- Around line 14-39: The constructor of GodotYamlConfigTableSource currently
only checks for blank strings but must reject absolute paths and any '.' or '..'
path segments to prevent directory traversal; update the constructor (the
GodotYamlConfigTableSource(...) method that sets TableName, ConfigRelativePath,
SchemaRelativePath) to normalize and validate configRelativePath and
schemaRelativePath: ensure Path.IsPathRooted returns false, split the path into
segments and reject any "." or ".." segments (or any empties), and only accept a
clean relative path (for schemaRelativePath apply the same checks when
non-null); throw ArgumentException with a clear message if validation fails so
invalid inputs never reach GodotYamlConfigLoader/ResetDirectory.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 34c2ce19-50dc-4aaa-aab0-6366c9e5f54d

📥 Commits

Reviewing files that changed from the base of the PR and between 39e3ecf and 40f5fd3.

📒 Files selected for processing (7)
  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
  • GFramework.Godot.Tests/GFramework.Godot.Tests.csproj
  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
  • GFramework.Godot/Config/GodotYamlConfigLoaderOptions.cs
  • GFramework.Godot/Config/GodotYamlConfigTableSource.cs
  • GFramework.Godot/Properties/AssemblyInfo.cs
  • docs/zh-CN/game/config-system.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Code Quality & Security
  • GitHub Check: Analyze (C#)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.csproj

📄 CodeRabbit inference engine (AGENTS.md)

**/*.csproj: Follow repository defaults: ImplicitUsings disabled, Nullable enabled, GenerateDocumentationFile enabled for shipped libraries, LangVersion generally preview in main libraries
Minimize new package dependencies; add them only when necessary and keep scope narrow

Files:

  • GFramework.Godot.Tests/GFramework.Godot.Tests.csproj
**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.cs: LoggerGenerator must automatically generate log fields and logging helper methods for classes decorated with [Log] attribute
PriorityGenerator must generate priority comparison implementations for classes decorated with [Priority] attribute
EnumExtensionsGenerator must generate enum extension capabilities for enums decorated with [GenerateEnumExtensions] attribute
ContextAwareGenerator must automatically implement IContextAware boilerplate logic for classes decorated with [ContextAware] attribute

**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> tags where applicable
XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax
Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, and generated code assumptions
Core framework components (Architecture, Module, System, Context, Registry, Service Module, Lifecycle types) MUST include high-level explanations of responsibilities, lifecycle, interactions with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and source generator pipelines MUST explain what is generated, why it is generated, semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling
Do not rely on implicit imports; declare every required using explicitly
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use namespace pattern GFramework.{Module}.{Feature} with PascalCase segments
Follow standard C# naming: Types/methods/properties/events/constants use PascalCase, interfaces use I prefix, parame...

Files:

  • GFramework.Godot/Properties/AssemblyInfo.cs
  • GFramework.Godot/Config/GodotYamlConfigLoaderOptions.cs
  • GFramework.Godot/Config/GodotYamlConfigTableSource.cs
  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
docs/**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Documentation must be located in docs/ directory with Chinese content in docs/zh-CN/

Files:

  • docs/zh-CN/game/config-system.md
{README.md,docs/**/*.md}

📄 CodeRabbit inference engine (AGENTS.md)

{README.md,docs/**/*.md}: Update the relevant README.md or docs/ page when behavior, setup steps, architecture guidance, or user-facing examples change
Keep code samples, package names, and command examples aligned with the current repository state
Prefer documenting behavior and design intent, not only API surface
For integration-oriented features such as AI-First config system, documentation MUST cover project directory layout, file conventions, required project/package wiring, minimal working usage example, and migration/compatibility notes
If an existing documentation page no longer reflects the current implementation, fixing the code without fixing the documentation is considered incomplete work
Do not rely on 'the code is self-explanatory' for framework features that consumers need to adopt; write the adoption path down so future users do not need to rediscover it from source

Files:

  • docs/zh-CN/game/config-system.md
docs/zh-CN/**/*.md

📄 CodeRabbit inference engine (AGENTS.md)

When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in docs/zh-CN/ in the same change

Files:

  • docs/zh-CN/game/config-system.md
🧠 Learnings (14)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to docs/zh-CN/**/*.md : When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in `docs/zh-CN/` in the same change
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.Godot.Tests/GFramework.Godot.Tests.csproj
  • GFramework.Godot/Properties/AssemblyInfo.cs
  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Source generator changes MUST be covered by generator tests

Applied to files:

  • GFramework.Godot.Tests/GFramework.Godot.Tests.csproj
  • GFramework.Godot/Properties/AssemblyInfo.cs
  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.csproj : Minimize new package dependencies; add them only when necessary and keep scope narrow

Applied to files:

  • GFramework.Godot.Tests/GFramework.Godot.Tests.csproj
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Keep abstractions projects free of implementation details and engine-specific dependencies

Applied to files:

  • GFramework.Godot.Tests/GFramework.Godot.Tests.csproj
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Preserve snapshot-based verification patterns already used in the repository for source generator tests

Applied to files:

  • GFramework.Godot.Tests/GFramework.Godot.Tests.csproj
  • GFramework.Godot/Properties/AssemblyInfo.cs
  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
📚 Learning: 2026-04-06T12:45:43.921Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:43.921Z
Learning: In the GFramework repository (GeWuYou/GFramework), even though `ImplicitUsings` is disabled in the `.csproj` files, the project uses a manual `GlobalUsings.cs` file with `global using` directives to provide common System namespaces (e.g., System, System.Threading, System.Threading.Tasks) project-wide. Do not flag missing System-level `using` imports in C# files within this repository, as they are covered by GlobalUsings.cs.

Applied to files:

  • GFramework.Godot.Tests/GFramework.Godot.Tests.csproj
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Keep tests focused on observable behavior, not implementation trivia

Applied to files:

  • GFramework.Godot/Properties/AssemblyInfo.cs
📚 Learning: 2026-04-06T12:45:43.921Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:43.921Z
Learning: In the GeWuYou/GFramework repository, C# files may omit explicit `using System*` imports because the project-wide `GlobalUsings.cs` (referenced via manual global `using` directives) supplies common namespaces (e.g., `System`, `System.Threading`, `System.Threading.Tasks`). During code review, do not flag missing `using System...` directives in `.cs` files as long as `GlobalUsings.cs` is present/used to provide those namespaces.

Applied to files:

  • GFramework.Godot/Properties/AssemblyInfo.cs
  • GFramework.Godot/Config/GodotYamlConfigLoaderOptions.cs
  • GFramework.Godot/Config/GodotYamlConfigTableSource.cs
  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to docs/zh-CN/**/*.md : When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in `docs/zh-CN/` in the same change

Applied to files:

  • docs/zh-CN/game/config-system.md
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to {README.md,docs/**/*.md} : For integration-oriented features such as AI-First config system, documentation MUST cover project directory layout, file conventions, required project/package wiring, minimal working usage example, and migration/compatibility notes

Applied to files:

  • docs/zh-CN/game/config-system.md
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Reuse existing architecture test infrastructure when relevant: `ArchitectureTestsBase<T>`, `SyncTestArchitecture`, `AsyncTestArchitecture`

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
🪛 GitHub Check: Build and Test
GFramework.Godot/Config/GodotYamlConfigLoader.cs

[failure] 461-461:
'FileAccess' is an ambiguous reference between 'Godot.FileAccess' and 'System.IO.FileAccess'


[failure] 454-454:
'FileAccess' is an ambiguous reference between 'Godot.FileAccess' and 'System.IO.FileAccess'


[failure] 461-461:
'FileAccess' is an ambiguous reference between 'Godot.FileAccess' and 'System.IO.FileAccess'


[failure] 454-454:
'FileAccess' is an ambiguous reference between 'Godot.FileAccess' and 'System.IO.FileAccess'


[failure] 461-461:
'FileAccess' is an ambiguous reference between 'Godot.FileAccess' and 'System.IO.FileAccess'


[failure] 454-454:
'FileAccess' is an ambiguous reference between 'Godot.FileAccess' and 'System.IO.FileAccess'


[failure] 461-461:
'FileAccess' is an ambiguous reference between 'Godot.FileAccess' and 'System.IO.FileAccess'


[failure] 454-454:
'FileAccess' is an ambiguous reference between 'Godot.FileAccess' and 'System.IO.FileAccess'


[failure] 461-461:
'FileAccess' is an ambiguous reference between 'Godot.FileAccess' and 'System.IO.FileAccess'


[failure] 454-454:
'FileAccess' is an ambiguous reference between 'Godot.FileAccess' and 'System.IO.FileAccess'

🪛 LanguageTool
docs/zh-CN/game/config-system.md

[uncategorized] ~317-~317: 能愿动词不能成为‘把’字句、‘被’字句的谓语动词。应该是:"会把……当前"。
Context: ...://...")交给底层YamlConfigLoader- 导出态:把当前注册会访问到的配置目录与 schema 文件同步到user://` 缓存,再交给底...

(wa3)

🔇 Additional comments (1)
GFramework.Godot/Config/GodotYamlConfigLoader.cs (1)

451-462: 文件已正确处理 FileAccess 命名冲突,无需修改。

第6行已明确包含别名导入:using FileAccess = Godot.FileAccess;。这个别名导入使得 FileAccess 在此文件中清晰地引用 Godot.FileAccess,完全消除了与 System.IO 中任何同名类型的歧义。代码在 455 和 462 行的使用正确,不存在编译失败的风险。无需使用 Godot.FileAccess.FileExists(...) 这样的完全限定形式。

			> Likely an incorrect or invalid review comment.

Comment thread docs/zh-CN/game/config-system.md Outdated
Comment thread GFramework.Godot/Config/GodotYamlConfigLoader.cs
Comment thread GFramework.Godot/Config/GodotYamlConfigTableSource.cs
@greptile-apps

greptile-apps Bot commented Apr 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds GodotYamlConfigLoader — a Godot-specific adapter that bridges the existing YamlConfigLoader with Godot's res:// / user:// path model. In editor mode the source directory is used directly (hot-reload remains available); in exported builds the declared YAML and schema assets are synchronised into a user:// runtime cache before the underlying loader reads them.

Key additions:

  • GodotYamlConfigEnvironment + GodotYamlConfigDirectoryEntry internal helpers make the Godot file-system boundary fully injectable, enabling tests to run without a real Godot runtime.
  • GodotYamlConfigTableSource performs strict path-safety validation on construction; a second defensive pass in NormalizeRelativePath catches corrupted metadata that bypassed the public constructor.
  • YamlConfigLoader gains an internal constructor accepting a canEnableHotReload guard delegate; GFramework.Game exposes this to GFramework.Godot via InternalsVisibleTo.
  • All previously-flagged issues (XML docs on internal types, sync-I/O rationale in remarks, Loader.EnableHotReload bypass warning, stale Microsoft.CodeAnalysis global using) have been resolved.

Confidence Score: 4/5

Safe to merge after the two minor clean-ups; no logic bugs or security issues found.

All previously-flagged issues have been resolved. Remaining findings are P2 style items: four unused global usings in GlobalUsings.cs and a missing tableName test case. Neither blocks correctness or safety; core logic, path-safety validation, editor/exported mode switching, and parent-before-child cache ordering are all correct and well-tested.

GFramework.Godot.Tests/GlobalUsings.cs (unused imports) and GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs (missing tableName validation test).

Important Files Changed

Filename Overview
GFramework.Godot/Config/GodotYamlConfigLoader.cs Core adapter class; well-documented with XML docs on all types/members including previously-flagged internal helpers, clear remarks explaining intentional synchronous I/O, and explicit Loader property warning. Logic is sound.
GFramework.Godot/Config/GodotYamlConfigTableSource.cs Path-safety validation is thorough (root prefix, colon, dot-segment checks); all public members documented correctly.
GFramework.Godot/Config/GodotYamlConfigLoaderOptions.cs Simple options record with sensible defaults and complete XML docs; no issues.
GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs Good integration coverage of editor/exported paths, parent-before-child ordering, directory-reset failure, and corrupted-metadata defence.
GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs Comprehensive path-safety matrix for configRelativePath and schemaRelativePath, but tableName null/whitespace validation branch is not tested (flagged).
GFramework.Godot.Tests/GlobalUsings.cs Four unused global using directives remain (System.Collections.Immutable, System.Globalization, System.Text, System.Text.Json) after the partial clean-up; flagged for removal.
GFramework.Game/Properties/AssemblyInfo.cs Adds InternalsVisibleTo("GFramework.Godot") to expose the internal YamlConfigLoader constructor; intentional and correctly scoped.
GFramework.Game/Config/YamlConfigLoader.cs Adds internal constructor accepting a canEnableHotReload guard delegate; well-documented and backward-compatible.

Reviews (6): Last reviewed commit: "refactor(tests): 移除未使用的 Roslyn 分析器引用" | Re-trigger Greptile

Comment thread GFramework.Godot/Config/GodotYamlConfigLoader.cs Outdated
Comment thread GFramework.Godot/Config/GodotYamlConfigLoader.cs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@GFramework.Godot/Config/GodotYamlConfigLoader.cs`:
- Around line 141-157: The loop over _options.TableSources groups by
NormalizeRelativePath then resets the target directory for each group, causing
child directories (e.g., a/b) to be deleted if a parent (a) is processed later;
fix by ordering the groups by path depth ascending (parents before children)
with a stable sort before iterating so ResetDirectory runs for parents first;
implement this by replacing the foreach over .GroupBy(...) with iteration over
.GroupBy(...).OrderBy(g => g.Key.Count(c => c == Path.DirectorySeparatorChar ||
c == '/')) (or an equivalent depth-calculation) and keep using
NormalizeRelativePath, ResetDirectory, and CopyYamlFilesInDirectory as before;
apply the same ordering change to the other similar grouping loop that also
enumerates _options.TableSources.
- Around line 347-350: NormalizeRelativePath currently only normalizes slashes
and can allow "../" or absolute segments that escape the intended
LoaderRootPath; update NormalizeRelativePath (and calling sites that feed
ResetDirectory / File.WriteAllBytes) to validate inputs strictly: after
normalizing slashes and trimming leading slashes, reject null/empty inputs and
throw on any path containing ".." segments, any rooted/absolute path
(Path.IsPathRooted or leading '/' or drive-letter like "C:"), and any path with
volume/URI markers (':'); ensure callers use the validated result (or
catch/propagate the exception) before combining with LoaderRootPath so no
relative traversal or absolute paths can escape the cache directory.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dd83c4a3-6523-407c-9dbe-f5cd4c35de59

📥 Commits

Reviewing files that changed from the base of the PR and between 40f5fd3 and 0ea3c0a.

📒 Files selected for processing (2)
  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
✅ Files skipped from review due to trivial changes (1)
  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (C#)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.cs: LoggerGenerator must automatically generate log fields and logging helper methods for classes decorated with [Log] attribute
PriorityGenerator must generate priority comparison implementations for classes decorated with [Priority] attribute
EnumExtensionsGenerator must generate enum extension capabilities for enums decorated with [GenerateEnumExtensions] attribute
ContextAwareGenerator must automatically implement IContextAware boilerplate logic for classes decorated with [ContextAware] attribute

**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> tags where applicable
XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax
Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, and generated code assumptions
Core framework components (Architecture, Module, System, Context, Registry, Service Module, Lifecycle types) MUST include high-level explanations of responsibilities, lifecycle, interactions with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and source generator pipelines MUST explain what is generated, why it is generated, semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling
Do not rely on implicit imports; declare every required using explicitly
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use namespace pattern GFramework.{Module}.{Feature} with PascalCase segments
Follow standard C# naming: Types/methods/properties/events/constants use PascalCase, interfaces use I prefix, parame...

Files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to docs/zh-CN/**/*.md : When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in `docs/zh-CN/` in the same change
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : All public, protected, and internal types and members MUST include XML documentation comments (`///`) with `<summary>`, `<param>`, `<returns>`, `<exception>`, and `<remarks>` tags where applicable

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Any change to public API, lifecycle semantics, module behavior, or extension points MUST update the related XML docs

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-06T12:45:43.921Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:43.921Z
Learning: In the GeWuYou/GFramework repository, C# files may omit explicit `using System*` imports because the project-wide `GlobalUsings.cs` (referenced via manual global `using` directives) supplies common namespaces (e.g., `System`, `System.Threading`, `System.Threading.Tasks`). During code review, do not flag missing `using System...` directives in `.cs` files as long as `GlobalUsings.cs` is present/used to provide those namespaces.

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
🔇 Additional comments (1)
GFramework.Godot/Config/GodotYamlConfigLoader.cs (1)

30-33: 内部 API 的 XML 契约文档仍缺失(与历史评论重复)。

GodotYamlConfigLoader internal 构造函数、GodotYamlConfigEnvironmentGodotYamlConfigDirectoryEntry 及其关键成员/方法仍未补齐 XML 注释(含约束、返回约定、异常与备注)。

Based on learnings: "Applies to **/*.cs : All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> tags where applicable".

Also applies to: 379-410, 412-450, 467-469

Comment thread GFramework.Godot/Config/GodotYamlConfigLoader.cs
Comment thread GFramework.Godot/Config/GodotYamlConfigLoader.cs
- 新增配置系统概述和核心能力介绍
- 添加Schema和YAML配置文件格式示例
- 提供推荐目录结构和接入模板
- 详细说明Generator集成和运行时加载流程
- 介绍VS Code工具和热重载功能
- 添加Godot引擎桥接适配器文档
- 说明运行时校验行为和错误处理机制
- 提供Architecture模块集成模板
- 记录当前限制和未来规划评估

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
GFramework.Godot/Config/GodotYamlConfigLoader.cs (1)

160-176: ⚠️ Potential issue | 🟠 Major

按稳定顺序处理父目录,否则子目录缓存会被后续重置抹掉。

这里先 GroupBy(...) 再直接遍历,顺序仍然取决于 TableSources 的首次出现位置。若输入里先有 a/b、后有 a,前者同步完成后,后者的 ResetDirectory(root/a) 会把刚写进去的 root/a/b 一并删掉,最终结果依赖配置声明顺序。

🧭 建议修复
         foreach (var group in _options.TableSources
-                     .GroupBy(static source => NormalizeRelativePath(source.ConfigRelativePath),
-                         StringComparer.Ordinal))
+                     .GroupBy(static source => NormalizeRelativePath(source.ConfigRelativePath), StringComparer.Ordinal)
+                     .OrderBy(static group => group.Key.Count(static ch => ch == '/'))
+                     .ThenBy(static group => group.Key, StringComparer.Ordinal))
         {
             cancellationToken.ThrowIfCancellationRequested();

             var representative = group.First();

As per coding guidelines: "Preserve deterministic behavior in registries, lifecycle orchestration, and generated outputs".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Godot/Config/GodotYamlConfigLoader.cs` around lines 160 - 176,
Grouped table source directories are iterated in input order, so a child
directory like "a/b" may be processed before its parent "a", and the later
ResetDirectory call on the parent can delete the child's output; to fix, sort
the groups returned by GroupBy(...) so parents are handled before children
(e.g., OrderBy on the normalized path depth or token count of
NormalizeRelativePath(source.ConfigRelativePath)) before the foreach, keeping
the existing
representative/CombinePath/CombineAbsolutePath/ResetDirectory/CopyYamlFilesInDirectory
usage and preserving stable tie-breakers (StringComparer.Ordinal) for equal
depths.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs`:
- Around line 17-24: Add missing test cases that exercise backslash and
Windows-drive/schema path variants so IsSafeRelativePath's branches are covered;
in GodotYamlConfigTableSourceTests.cs update the existing parameterized test
(the TestCase lines shown) to include examples like "..\\outside", ".\\monster",
"monster\\..\\outside", "monster\\.\\child", "C:\\monster", "res:\\\\monster",
and "user:\\\\monster" (and their absolute/backslash combos) so the regression
that handles '\' and Windows drive letters/schemas fails before the fix and
passes afterwards; ensure you add the same set of cases for the other group
mentioned (lines 37-44) to fully cover both test groups.

---

Duplicate comments:
In `@GFramework.Godot/Config/GodotYamlConfigLoader.cs`:
- Around line 160-176: Grouped table source directories are iterated in input
order, so a child directory like "a/b" may be processed before its parent "a",
and the later ResetDirectory call on the parent can delete the child's output;
to fix, sort the groups returned by GroupBy(...) so parents are handled before
children (e.g., OrderBy on the normalized path depth or token count of
NormalizeRelativePath(source.ConfigRelativePath)) before the foreach, keeping
the existing
representative/CombinePath/CombineAbsolutePath/ResetDirectory/CopyYamlFilesInDirectory
usage and preserving stable tie-breakers (StringComparer.Ordinal) for equal
depths.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 47e1d840-51ff-44ba-9650-00c38618e823

📥 Commits

Reviewing files that changed from the base of the PR and between 0ea3c0a and 411d4cb.

📒 Files selected for processing (4)
  • GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs
  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
  • GFramework.Godot/Config/GodotYamlConfigTableSource.cs
  • docs/zh-CN/game/config-system.md
✅ Files skipped from review due to trivial changes (1)
  • docs/zh-CN/game/config-system.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Analyze (C#)
  • GitHub Check: Build and Test
  • GitHub Check: Code Quality & Security
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.cs: LoggerGenerator must automatically generate log fields and logging helper methods for classes decorated with [Log] attribute
PriorityGenerator must generate priority comparison implementations for classes decorated with [Priority] attribute
EnumExtensionsGenerator must generate enum extension capabilities for enums decorated with [GenerateEnumExtensions] attribute
ContextAwareGenerator must automatically implement IContextAware boilerplate logic for classes decorated with [ContextAware] attribute

**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> tags where applicable
XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax
Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, and generated code assumptions
Core framework components (Architecture, Module, System, Context, Registry, Service Module, Lifecycle types) MUST include high-level explanations of responsibilities, lifecycle, interactions with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and source generator pipelines MUST explain what is generated, why it is generated, semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling
Do not rely on implicit imports; declare every required using explicitly
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use namespace pattern GFramework.{Module}.{Feature} with PascalCase segments
Follow standard C# naming: Types/methods/properties/events/constants use PascalCase, interfaces use I prefix, parame...

Files:

  • GFramework.Godot/Config/GodotYamlConfigTableSource.cs
  • GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs
  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
🧠 Learnings (15)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to docs/zh-CN/**/*.md : When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in `docs/zh-CN/` in the same change
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to {README.md,docs/**/*.md} : For integration-oriented features such as AI-First config system, documentation MUST cover project directory layout, file conventions, required project/package wiring, minimal working usage example, and migration/compatibility notes
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Validate external or user-controlled input before it reaches file system, serialization, reflection, code generation, or process boundaries

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigTableSource.cs
  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Do not build command strings, file paths, type names, or generated code from untrusted input without strict validation or allow-listing

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigTableSource.cs
  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-06T12:45:43.921Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:43.921Z
Learning: In the GeWuYou/GFramework repository, C# files may omit explicit `using System*` imports because the project-wide `GlobalUsings.cs` (referenced via manual global `using` directives) supplies common namespaces (e.g., `System`, `System.Threading`, `System.Threading.Tasks`). During code review, do not flag missing `using System...` directives in `.cs` files as long as `GlobalUsings.cs` is present/used to provide those namespaces.

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigTableSource.cs
  • GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs
  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Source generator changes MUST be covered by generator tests

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Preserve snapshot-based verification patterns already used in the repository for source generator tests

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : All public, protected, and internal types and members MUST include XML documentation comments (`///`) with `<summary>`, `<param>`, `<returns>`, `<exception>`, and `<remarks>` tags where applicable

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Any change to public API, lifecycle semantics, module behavior, or extension points MUST update the related XML docs

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, and generated code assumptions

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Preserve deterministic behavior in registries, lifecycle orchestration, and generated outputs

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs

Comment thread GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs
- 实现 GodotYamlConfigLoader 类,提供 YAML 配置加载适配层
- 支持编辑器态直接读取项目目录和导出态运行时缓存同步
- 添加 GodotYamlConfigEnvironment 抽象处理 Godot 路径和文件访问
- 实现配置文件同步机制,支持 YAML 和 schema 文件复制
- 提供热重载功能,在编辑器态下支持配置实时更新
- 添加完整的单元测试验证各种场景下的配置加载行为

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
GFramework.Godot/Config/GodotYamlConfigLoader.cs (1)

374-392: ⚠️ Potential issue | 🟠 Major

相对路径校验还需要拒绝 :,否则 Windows 上仍会落到文件系统异常。

现在只拦截了 rooted path 和盘符前缀,像 schemas:bad/file.json 这类带 : 的片段仍能通过 NormalizeRelativePath。这些值继续进入 Directory.CreateDirectory / File.WriteAllBytes 时,会在 Windows 上直接炸成原生路径异常,等于又绕过了这里新增的防御式校验。

As per coding guidelines: "Validate external or user-controlled input before it reaches file system, serialization, reflection, code generation, or process boundaries."

In .NET, how do Path.IsPathRooted and Windows file APIs treat relative paths containing ':' such as 'schemas:bad/file.json'?
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Godot/Config/GodotYamlConfigLoader.cs` around lines 374 - 392,
NormalizeRelativePath currently misses segments containing ':' (e.g.,
"schemas:bad/file.json") which can still reach
Directory.CreateDirectory/File.WriteAllBytes and cause native Windows path
errors; update the validation in NormalizeRelativePath (and/or the segments.Any
check) to reject any path or segment containing ':' (e.g., check normalizedPath
and/or segments for ':' or use segments.Any(segment => segment.Contains(':'))),
keeping the existing ArgumentException style and using nameof(relativePath) so
such inputs are refused before hitting the filesystem; also ensure
HasWindowsDrivePrefix logic remains unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@GFramework.Godot/Config/GodotYamlConfigLoader.cs`:
- Around line 174-175: The ResetDirectory/Directory.CreateDirectory calls in
GodotYamlConfigLoader.LoadAsync currently let raw IO exceptions escape; wrap the
filesystem operations (ResetDirectory,
Directory.CreateDirectory(targetDirectoryPath) and the CopyYamlFilesInDirectory
invocation) in try/catch blocks that catch IOException,
UnauthorizedAccessException (and optionally PathTooLongException) and rethrow a
ConfigLoadException with the caught exception as the InnerException and a clear
contextual message; apply the same pattern to the other similar filesystem
touches in this class (the ResetDirectory usage and the
Directory.CreateDirectory usage near the CopyYamlFilesInDirectory call and the
later directory-creation block) so callers always receive ConfigLoadException
instead of raw system exceptions.
- Around line 21-27: Update the XML docs for the new public constructor
GodotYamlConfigLoader(GodotYamlConfigLoaderOptions) and the EnableHotReload
member to include thrown exceptions and usage constraints: add <exception> tags
for ArgumentNullException (when options is null), ArgumentException (for invalid
options values), and InvalidOperationException (when environment/state disallows
initialization), and add a <remarks> entry stating that EnableHotReload can only
be set/used when the source directory is directly accessible (i.e.,
non-embedded/read-only sources); also mirror these doc updates on the related
overload/initializer (the ctor that takes GodotYamlConfigLoaderOptions and
GodotYamlConfigEnvironment) so all public entry points declare these exceptions
and the hot-reload constraint.

---

Duplicate comments:
In `@GFramework.Godot/Config/GodotYamlConfigLoader.cs`:
- Around line 374-392: NormalizeRelativePath currently misses segments
containing ':' (e.g., "schemas:bad/file.json") which can still reach
Directory.CreateDirectory/File.WriteAllBytes and cause native Windows path
errors; update the validation in NormalizeRelativePath (and/or the segments.Any
check) to reject any path or segment containing ':' (e.g., check normalizedPath
and/or segments for ':' or use segments.Any(segment => segment.Contains(':'))),
keeping the existing ArgumentException style and using nameof(relativePath) so
such inputs are refused before hitting the filesystem; also ensure
HasWindowsDrivePrefix logic remains unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 48aa3b80-8b12-4e12-bbe9-1d9d05512092

📥 Commits

Reviewing files that changed from the base of the PR and between 411d4cb and e746297.

📒 Files selected for processing (2)
  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build and Test
  • GitHub Check: Code Quality & Security
  • GitHub Check: Analyze (C#)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.cs: LoggerGenerator must automatically generate log fields and logging helper methods for classes decorated with [Log] attribute
PriorityGenerator must generate priority comparison implementations for classes decorated with [Priority] attribute
EnumExtensionsGenerator must generate enum extension capabilities for enums decorated with [GenerateEnumExtensions] attribute
ContextAwareGenerator must automatically implement IContextAware boilerplate logic for classes decorated with [ContextAware] attribute

**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> tags where applicable
XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax
Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, and generated code assumptions
Core framework components (Architecture, Module, System, Context, Registry, Service Module, Lifecycle types) MUST include high-level explanations of responsibilities, lifecycle, interactions with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and source generator pipelines MUST explain what is generated, why it is generated, semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling
Do not rely on implicit imports; declare every required using explicitly
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use namespace pattern GFramework.{Module}.{Feature} with PascalCase segments
Follow standard C# naming: Types/methods/properties/events/constants use PascalCase, interfaces use I prefix, parame...

Files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
🧠 Learnings (12)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to docs/zh-CN/**/*.md : When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in `docs/zh-CN/` in the same change
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Any change to public API, lifecycle semantics, module behavior, or extension points MUST update the related XML docs

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : All public, protected, and internal types and members MUST include XML documentation comments (`///`) with `<summary>`, `<param>`, `<returns>`, `<exception>`, and `<remarks>` tags where applicable

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, and generated code assumptions

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Validate external or user-controlled input before it reaches file system, serialization, reflection, code generation, or process boundaries

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Do not build command strings, file paths, type names, or generated code from untrusted input without strict validation or allow-listing

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-06T12:45:43.921Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:43.921Z
Learning: In the GeWuYou/GFramework repository, C# files may omit explicit `using System*` imports because the project-wide `GlobalUsings.cs` (referenced via manual global `using` directives) supplies common namespaces (e.g., `System`, `System.Threading`, `System.Threading.Tasks`). During code review, do not flag missing `using System...` directives in `.cs` files as long as `GlobalUsings.cs` is present/used to provide those namespaces.

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Source generator changes MUST be covered by generator tests

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
🔇 Additional comments (1)
GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs (1)

52-222: 这组回归用例补得很到位。

导出态缓存同步、编辑器态直读、热重载开关、父/子目录顺序,以及损坏元数据路径这几条关键行为都覆盖到了,后续再改加载器时更容易第一时间发现回归。

Based on learnings: "Public API changes must be covered by unit or integration tests" and "Regression fixes should include a test that fails before the fix and passes after it."

Comment thread GFramework.Godot/Config/GodotYamlConfigLoader.cs
Comment thread GFramework.Godot/Config/GodotYamlConfigLoader.cs Outdated
GeWuYou added 2 commits April 11, 2026 07:28
- 为构造函数添加ArgumentNullException和ArgumentException异常说明
- 为EnableHotReload方法添加InvalidOperationException异常说明
- 重构ResetDirectory方法以捕获目录操作异常并包装为ConfigLoadException
- 添加detail参数到CreateConfigLoadException方法用于提供更详细的错误信息
- 新增单元测试验证运行时缓存目录重置失败时的异常处理
- 添加GodotYamlConfigTableSourceTests测试类验证安全相对路径约束
- 添加了详细的 XML 文档注释说明方法功能和参数
- 补充了异常情况的详细说明包括 ArgumentNullException 和 ConfigLoadException
- 添加了关于运行时缓存同步执行原因的技术备注
- 保留了原有的继承特性标记并添加了完整的文档结构

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@GFramework.Godot/Config/GodotYamlConfigLoader.cs`:
- Around line 596-612: Check the result of directory.ListDirBegin() and handle
non-OK Godot.Error values: call var err = directory.ListDirBegin(); if err !=
Error.Ok return null (or propagate the error) before calling GetNext(), and
ensure directory.ListDirEnd() is still called when appropriate; update the code
around the directory variable and the loop that creates
List<GodotYamlConfigDirectoryEntry> (which uses GetNext() and CurrentIsDir()) so
failures return null (matching DirAccess.Open failure semantics) rather than an
empty list.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5b8663d9-1d53-4f3f-b660-0f44b3a22726

📥 Commits

Reviewing files that changed from the base of the PR and between e746297 and 1bf5d28.

📒 Files selected for processing (3)
  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
  • GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs
  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • GFramework.Godot.Tests/Config/GodotYamlConfigTableSourceTests.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Code Quality & Security
  • GitHub Check: Analyze (C#)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.cs: LoggerGenerator must automatically generate log fields and logging helper methods for classes decorated with [Log] attribute
PriorityGenerator must generate priority comparison implementations for classes decorated with [Priority] attribute
EnumExtensionsGenerator must generate enum extension capabilities for enums decorated with [GenerateEnumExtensions] attribute
ContextAwareGenerator must automatically implement IContextAware boilerplate logic for classes decorated with [ContextAware] attribute

**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> tags where applicable
XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax
Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, and generated code assumptions
Core framework components (Architecture, Module, System, Context, Registry, Service Module, Lifecycle types) MUST include high-level explanations of responsibilities, lifecycle, interactions with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and source generator pipelines MUST explain what is generated, why it is generated, semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling
Do not rely on implicit imports; declare every required using explicitly
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use namespace pattern GFramework.{Module}.{Feature} with PascalCase segments
Follow standard C# naming: Types/methods/properties/events/constants use PascalCase, interfaces use I prefix, parame...

Files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
🧠 Learnings (15)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to docs/zh-CN/**/*.md : When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in `docs/zh-CN/` in the same change
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Source generator changes MUST be covered by generator tests

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.Tests.cs : Preserve snapshot-based verification patterns already used in the repository for source generator tests

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
📚 Learning: 2026-04-06T12:45:43.921Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:43.921Z
Learning: In the GeWuYou/GFramework repository, C# files may omit explicit `using System*` imports because the project-wide `GlobalUsings.cs` (referenced via manual global `using` directives) supplies common namespaces (e.g., `System`, `System.Threading`, `System.Threading.Tasks`). During code review, do not flag missing `using System...` directives in `.cs` files as long as `GlobalUsings.cs` is present/used to provide those namespaces.

Applied to files:

  • GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs
  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Any change to public API, lifecycle semantics, module behavior, or extension points MUST update the related XML docs

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : All public, protected, and internal types and members MUST include XML documentation comments (`///`) with `<summary>`, `<param>`, `<returns>`, `<exception>`, and `<remarks>` tags where applicable

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, and generated code assumptions

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Preserve deterministic behavior in registries, lifecycle orchestration, and generated outputs

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Validate external or user-controlled input before it reaches file system, serialization, reflection, code generation, or process boundaries

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : Do not build command strings, file paths, type names, or generated code from untrusted input without strict validation or allow-listing

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
📚 Learning: 2026-04-10T09:05:17.290Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T09:05:17.290Z
Learning: Applies to **/*.cs : If a framework abstraction changes meaning or intended usage, update the explanatory comments in code as part of the same change

Applied to files:

  • GFramework.Godot/Config/GodotYamlConfigLoader.cs
🔇 Additional comments (9)
GFramework.Godot/Config/GodotYamlConfigLoader.cs (4)

1-85: 构造函数和初始化逻辑实现良好。

构造函数正确地:

  • 使用 ArgumentNullException.ThrowIfNull 验证空参数
  • 验证 SourceRootPathRuntimeCacheRootPath 不为空白
  • 完整的 XML 文档包含所有 <exception> 标签
  • 通过 GodotYamlConfigEnvironment 抽象解耦了 Godot 引擎依赖

之前审查中提到的异常文档要求已完整实现。


185-227: 运行时缓存同步逻辑正确处理了父/子目录顺序。

SynchronizeRuntimeCache 通过 .OrderBy(static group => CountPathDepth(group.Key)) 确保父目录先于子目录被重置,避免了之前审查中指出的缓存丢失问题。路径深度计算简单有效。


409-432: 路径遍历防护实现完整。

NormalizeRelativePath 方法正确拒绝:

  • / 开头的路径
  • Godot 特殊路径前缀(res://user://
  • Windows 驱动器前缀
  • 包含 ... 的路径段
  • 通过 Path.IsPathRooted 检测的其他根路径

这满足了编码指南中"验证外部或用户控制的输入,防止其到达文件系统边界"的要求。


475-659: 环境抽象和目录条目类型文档完整。

GodotYamlConfigEnvironmentGodotYamlConfigDirectoryEntry 现在包含完整的 XML 文档,解释了:

  • 为什么需要该抽象(编辑器态与导出态的访问差异)
  • 各委托的输入约束和返回约定
  • EnumerateDirectory 返回 null 的语义
  • Godot 路径与普通路径的处理差异

这满足了之前审查中对内部类型文档的要求。

GFramework.Godot.Tests/Config/GodotYamlConfigLoaderTests.cs (5)

15-47: 测试夹具设置和清理实现正确。

使用 Guid.NewGuid() 创建独立的临时目录确保测试隔离,TearDown 正确清理资源。这是可靠测试实践的良好示例。


56-106: 导出态与编辑器态行为测试覆盖全面。

两个测试用例正确验证了:

  • 导出态(isEditor: false):文件同步到缓存、CanEnableHotReload == falseLoaderRootPath 指向缓存目录
  • 编辑器态(isEditor: true):直接使用项目目录、CanEnableHotReload == true、不创建缓存目录

断言覆盖了加载器状态和注册表内容两个维度。


183-203: 缓存目录重置失败的错误处理测试设计巧妙。

第 187 行通过 WriteFile(_userRoot, "config_cache", "occupied") 在缓存路径创建一个文件而非目录,当加载器尝试在该路径下创建子目录时会触发 IOException。测试正确验证了:

  • 异常类型为 ConfigLoadException
  • FailureKindConfigFileReadFailed
  • 诊断信息包含表名和路径
  • 内部异常为 IOException

208-248: 防御式路径验证测试使用反射绕过构造函数约束。

使用 RuntimeHelpers.GetUninitializedObject 和反射设置字段来创建"损坏的"配置源对象是测试防御式代码的有效方法。这验证了即使调用方绕过了 GodotYamlConfigTableSource 的公开构造校验,加载器内部的 NormalizeRelativePath 仍会拒绝危险路径。

测试期望 ParamName == "relativePath"NormalizeRelativePath 中的 nameof(relativePath) 参数一致。


389-424: 反射辅助方法文档清晰。

CreateUnsafeTableSourceSetAutoPropertyBackingField 的 XML 文档清楚说明了这些方法的用途——构造绕过验证的测试对象。这种测试策略能有效验证加载器的纵深防御能力。

Comment thread GFramework.Godot/Config/GodotYamlConfigLoader.cs
GeWuYou added 5 commits April 11, 2026 07:36
- 将Godot.FileAccess重命名为FileAccess以避免命名冲突
- 优化了配置加载器中的文件操作引用
- 提高了代码的可读性和维护性
- 在 GodotYamlConfigLoader 中增加对路径中冒号字符的验证,防止 Windows 无效名称和 ADS 类似语法
- 新增 GodotYamlConfigTableSource 类用于描述配置表来源信息,并实现安全路径验证
- 添加对配置路径和 schema 路径的严格安全检查,拒绝包含根路径、遍历标记或冒号字符的路径
- 扩展测试用例覆盖多种不安全路径场景,包括路径遍历、绝对路径前缀和冒号字符
- 为新功能添加完整的单元测试验证安全路径验证逻辑
- 将Godot.FileAccess别名为FileAccess以提高代码可读性
- 保持现有功能不变,仅优化命名空间引用方式
- 在 GodotYamlConfigLoaderTests 中添加 GFramework.Game.Config 引用
- 从 GodotYamlConfigTableSourceTests 中移除未使用的 System 引用
- 新增 GlobalUsings.cs 文件统一管理所有全局引用
- 将常用的系统命名空间配置为全局引用以减少重复导入
- 优化测试代码的引用管理和项目结构
- 添加了 ListDirBegin 方法的错误检查
- 在遇到错误时返回 null 避免异常
- 确保目录遍历前检查操作状态
Comment thread GFramework.Godot/Config/GodotYamlConfigLoader.cs
- 新增游戏内容配置系统详细文档,涵盖 YAML 配置、JSON Schema 结构描述
- 添加运行时只读查询、Source Generator 类型生成等功能说明
- 提供推荐目录结构、Schema 示例和 YAML 示例配置
- 添加 VS Code 插件配置浏览、校验和表单编辑功能介绍
- 提供 Godot 文本配置桥接、运行时读取模板和 Architecture 接入指南
- 说明热重载、跨表引用、查询辅助等高级功能使用方法
- 添加开发期工具和当前限制说明,提供完整的配置系统接入流程
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 11, 2026
- 添加事件抽象依赖项到YAML配置加载器
- 添加YamlDotNet序列化库依赖项
- 为Godot平台配置文件访问添加别名引用
- 在测试文件中添加配置依赖项引用
Comment thread GFramework.Godot.Tests/GlobalUsings.cs Outdated
- 从 GlobalUsings.cs 中删除 Microsoft.CodeAnalysis 的全局引用
- 清理测试项目中不再需要的依赖项
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant