Skip to content

feat(config): 添加配置模块集成测试和架构模块支持#197

Merged
GeWuYou merged 4 commits into
mainfrom
feat/config-module-architecture-integration
Apr 9, 2026
Merged

feat(config): 添加配置模块集成测试和架构模块支持#197
GeWuYou merged 4 commits into
mainfrom
feat/config-module-architecture-integration

Conversation

@GeWuYou

@GeWuYou GeWuYou commented Apr 9, 2026

Copy link
Copy Markdown
Owner
  • 新增 ArchitectureConfigIntegrationTests 验证配置模块在架构场景下的接入链路
  • 添加 GameConfigModule 作为 Architecture 官方配置模块接入入口
  • 实现模块生命周期管理,统一完成注册表暴露和首次加载
  • 添加配置模块防止重复安装到多个架构的保护机制
  • 验证配置模块在其他 utility 初始化前完成首次加载的顺序
  • 更新中文文档详细说明配置系统接入模板和架构集成方式

Summary by Sourcery

为基于 Architecture 的宿主引入官方的 GameConfigModule,并通过测试与文档更新验证其集成效果。

New Features:

  • 新增 GameConfigModule 作为基于 Architecture 初始化时的官方配置模块入口,封装 GameConfigBootstrap 的生命周期管理、注册表暴露,以及可选的热重载控制。

Enhancements:

  • 通过生命周期钩子和生命周期工具,将 GameConfigModule 接入 Architecture 生命周期,确保配置在各类工具初始化前加载,并在拆卸时正确清理。
  • 扩展集成测试,以覆盖在 Architecture 中基于模块的配置加载,包括依赖工具的初始化顺序,以及防止在多个 Architecture 实例间复用同一个模块实例。

Documentation:

  • 更新中文配置系统文档,推荐使用 GameConfigModule 作为在 Architecture 中集成配置系统的首选方式,包括生命周期说明、热重载用法,以及与直接使用 GameConfigBootstrap 的对比。
Original summary in English

Summary by Sourcery

Introduce an official GameConfigModule for Architecture-based hosts and validate its integration via tests and documentation updates.

New Features:

  • Add GameConfigModule as the official configuration module entry point for Architecture-based initialization, encapsulating GameConfigBootstrap lifecycle, registry exposure, and optional hot-reload control.

Enhancements:

  • Wire GameConfigModule into architecture lifecycle via lifecycle hooks and a lifetime utility to ensure config is loaded before utilities and cleaned up on teardown.
  • Extend integration tests to cover module-based config loading within Architecture, including dependent utility initialization order and preventing reuse of a single module instance across multiple architectures.

Documentation:

  • Update Chinese configuration system documentation to recommend GameConfigModule as the preferred integration path for Architecture, including lifecycle, hot-reload usage, and comparison with direct GameConfigBootstrap usage.

Summary by CodeRabbit

  • 新功能

    • 新增统一配置模块,简化配置集成、生命周期与热重载控制,并暴露共享注册表与加载器。
  • 修复

    • 改进异步等待策略以避免在阻塞的同步上下文上死锁或阻塞;
    • 加强模块安装约束,防止重复重用、迟装或未消费实例导致的不一致。
  • 测试

    • 增加多项集成测试与测试辅助工具,覆盖配置可见性、安装时序与同步桥回归。
  • 文档

    • 更新配置系统文档,推荐基于新模块的初始化与热重载方案。

- 新增 ArchitectureConfigIntegrationTests 验证配置模块在架构场景下的接入链路
- 添加 GameConfigModule 作为 Architecture 官方配置模块接入入口
- 实现模块生命周期管理,统一完成注册表暴露和首次加载
- 添加配置模块防止重复安装到多个架构的保护机制
- 验证配置模块在其他 utility 初始化前完成首次加载的顺序
- 更新中文文档详细说明配置系统接入模板和架构集成方式

� Conflicts:
�	docs/zh-CN/game/config-system.md
@coderabbitai

coderabbitai Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

新增公用 GameConfigModule 以模块化方式管理 GameConfigBootstrap 的安装与生命周期;在多处 await 添加 ConfigureAwait(false);重构并扩展集成测试以验证模块安装语义、初始化顺序、同步阻塞场景及模块重用约束;更新中文文档示例以推荐使用模块化方案。

Changes

Cohort / File(s) Summary
配置模块核心实现
GFramework.Game/Config/GameConfigModule.cs
新增公有密封类 GameConfigModule : IArchitectureModule,封装 GameConfigBootstrap,在 Install 中做原子安装校验、注册 IConfigRegistry 与生命周期工具、在 BeforeUtilityInit 钩子同步桥接并触发 InitializeAsync(),并暴露 IsInitialized/IsHotReloadEnabled/Loader 与热重载控制方法。
引导与加载 await 行为调整
GFramework.Game/Config/GameConfigBootstrap.cs, GFramework.Game/Config/YamlConfigLoader.cs, GFramework.Game/Config/YamlConfigSchemaValidator.cs
将若干异步等待调用改为使用 .ConfigureAwait(false)(包括 bootstrap 初始化、Yaml 加载/重载、模式文件读取、延时/锁获取等),并在 bootstrap 文档备注说明同步生命周期钩子桥接导致的需求。
集成测试与测试辅助类型
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs, GFramework.Game.Tests/.../ModuleOnlyArchitecture, .../ReadyOnlyArchitecture, .../ConfigAwareProbeUtility
重构并扩展集成测试:新增 [SetUp]/[TearDown] 清理 GameContext,重命名并新增多项测试用例以覆盖配置在工具 OnInit 时的可见性、不同安装时序、禁止重复使用同一模块实例、在阻塞(非 pumping)SynchronizationContext 下同步桥接的正确性;新增 RunBlockingOnSynchronizationContextNonPumpingSynchronizationContext 等测试工具类型。
文档更新
docs/zh-CN/game/config-system.md
将示例和运行时组件列表更新为推荐使用 GameConfigModule,示例改为 InstallModule(_configModule) 并使用模块热重载 API,移除显式 bootstrap.InitializeAsync() 与手动 Dispose() 的模式。

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant Architecture
    participant GameConfigModule
    participant GameConfigBootstrap
    participant ModuleLifetimeUtility

    Developer->>Architecture: InstallModule(module)
    Architecture->>GameConfigModule: Install(architecture)
    GameConfigModule->>Architecture: RegisterUtility(IConfigRegistry)
    GameConfigModule->>Architecture: RegisterUtility(ModuleLifetimeUtility)
    GameConfigModule->>Architecture: InstallLifecycleHook(BeforeUtilityInit)

    Developer->>Architecture: InitializeAsync()
    Architecture->>GameConfigModule: ExecuteHook(BeforeUtilityInit)
    GameConfigModule->>GameConfigBootstrap: InitializeAsync() (sync bridge, awaits .ConfigureAwait(false))
    GameConfigBootstrap->>GameConfigBootstrap: Load configs/tables (await .ConfigureAwait(false))
    Architecture->>ModuleLifetimeUtility: OnInit()

    Developer->>Architecture: DestroyAsync()
    Architecture->>ModuleLifetimeUtility: OnDestroy()
    ModuleLifetimeUtility->>GameConfigBootstrap: Dispose()
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 标题准确总结了主要变更:添加配置模块集成测试和 Architecture 模块支持,与代码变更内容(新增 GameConfigModule、ArchitectureConfigIntegrationTests 等)高度相关。
Docstring Coverage ✅ Passed Docstring coverage is 84.85% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/config-module-architecture-integration

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

@sourcery-ai

sourcery-ai Bot commented Apr 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

引入 GameConfigModule 作为基于 Architecture 的宿主的官方配置集成入口,将其通过模块和生命周期钩子接入架构生命周期,新增集成测试用于验证初始化顺序和模块复用保护,并更新中文文档以推荐基于模块的新集成模式。

使用 GameConfigModule 的 Architecture 初始化时序图

sequenceDiagram
    participant Architecture as GameArchitecture
    participant Module as GameConfigModule
    participant Lifecycle as ArchitectureLifecycle
    participant Hook as BootstrapInitializationHook
    participant Bootstrap as GameConfigBootstrap
    participant Probe as ConfigAwareProbeUtility
    participant Registry as IConfigRegistry
    participant MonsterTable as MonsterTable

    Architecture->>Module: new GameConfigModule(options)
    Architecture->>Architecture: InstallModule(Module)
    Architecture->>Module: Install(this)
    Module->>Architecture: RegisterUtility(Registry)
    Module->>Architecture: RegisterUtility(ModuleBootstrapLifetimeUtility)
    Module->>Architecture: RegisterLifecycleHook(Hook)

    Architecture->>Lifecycle: InitializeAsync()

    Note over Lifecycle,Hook: BeforeUtilityInit phase
    Lifecycle->>Hook: OnPhase(BeforeUtilityInit, Architecture)
    Hook->>Bootstrap: InitializeAsync()
    Bootstrap-->>Hook: Config tables loaded

    Note over Lifecycle,Architecture: Utility initialization phase
    Lifecycle->>Architecture: Initialize utilities
    Architecture->>Probe: RegisterUtility(Probe)
    Architecture->>Probe: OnInit()
    Probe->>Registry: GetMonsterTable()
    Registry-->>Probe: MonsterTable
    Probe->>MonsterTable: Get(1)
    MonsterTable-->>Probe: Monster row
    Probe->>MonsterTable: FindByFaction("dungeon")
    MonsterTable-->>Probe: Monsters in dungeon faction
    Probe-->>Architecture: InitializedWithLoadedConfig = true

    Note over Architecture,Module: Destruction phase
    Architecture->>Architecture: DestroyAsync()
    Architecture->>ModuleBootstrapLifetimeUtility: OnDestroy()
    ModuleBootstrapLifetimeUtility->>Bootstrap: Dispose()
    Bootstrap-->>ModuleBootstrapLifetimeUtility: Hot reload stopped, resources freed
Loading

GameConfigModule 及相关生命周期类型类图

classDiagram
    class GameConfigModule {
        - GameConfigBootstrap _bootstrap
        - ModuleBootstrapLifetimeUtility _lifetimeUtility
        - int _installState
        + GameConfigModule(GameConfigBootstrapOptions options)
        + IConfigRegistry Registry
        + bool IsInitialized
        + bool IsHotReloadEnabled
        + YamlConfigLoader Loader
        + void Install(IArchitecture architecture)
        + void StartHotReload(YamlConfigHotReloadOptions options)
        + void StopHotReload()
    }

    class GameConfigBootstrap {
        + IConfigRegistry Registry
        + bool IsInitialized
        + bool IsHotReloadEnabled
        + YamlConfigLoader Loader
        + ValueTask InitializeAsync()
        + void StartHotReload(YamlConfigHotReloadOptions options)
        + void StopHotReload()
        + void Dispose()
    }

    class ModuleBootstrapLifetimeUtility {
        + ModuleBootstrapLifetimeUtility(GameConfigBootstrap bootstrap)
        + void OnInit()
        + void OnDestroy()
    }

    class BootstrapInitializationHook {
        + BootstrapInitializationHook(GameConfigBootstrap bootstrap)
        + void OnPhase(ArchitecturePhase phase, IArchitecture architecture)
    }

    class IArchitectureModule {
        <<interface>>
        + void Install(IArchitecture architecture)
    }

    class IArchitecture {
        <<interface>>
        + void RegisterUtility(object utility)
        + void RegisterLifecycleHook(IArchitectureLifecycleHook hook)
    }

    class IArchitectureLifecycleHook {
        <<interface>>
        + void OnPhase(ArchitecturePhase phase, IArchitecture architecture)
    }

    class AbstractContextUtility {
        <<abstract>>
        + void OnInit()
        + void OnDestroy()
    }

    class ArchitecturePhase {
        <<enumeration>>
        BeforeUtilityInit
        OtherPhases
    }

    class IConfigRegistry {
        <<interface>>
    }

    class YamlConfigLoader {
    }

    class YamlConfigHotReloadOptions {
    }

    class GameConfigBootstrapOptions {
    }

    GameConfigModule ..|> IArchitectureModule
    GameConfigModule o-- GameConfigBootstrap
    GameConfigModule o-- ModuleBootstrapLifetimeUtility
    GameConfigModule ..> BootstrapInitializationHook
    GameConfigModule ..> IArchitecture
    GameConfigModule ..> YamlConfigHotReloadOptions
    GameConfigModule ..> GameConfigBootstrapOptions
    GameConfigModule ..> IConfigRegistry
    GameConfigModule ..> YamlConfigLoader

    ModuleBootstrapLifetimeUtility ..|> AbstractContextUtility
    BootstrapInitializationHook ..|> IArchitectureLifecycleHook

    BootstrapInitializationHook ..> GameConfigBootstrap
    ModuleBootstrapLifetimeUtility ..> GameConfigBootstrap

    IArchitectureLifecycleHook ..> ArchitecturePhase
    IArchitectureLifecycleHook ..> IArchitecture

    IArchitecture ..> IConfigRegistry
    IArchitecture ..> AbstractContextUtility
Loading

文件级变更

Change Details Files
添加 GameConfigModule,以模块语义将 GameConfigBootstrap 集成进 Architecture 生命周期,提供热重载控制,并防止重复安装。
  • GameConfigBootstrap 封装在密封类 GameConfigModule 中,并实现 IArchitectureModule
  • 对外暴露底层 bootstrap 的 Registry、初始化/热重载状态以及 Loader 以供使用方访问。
  • 将配置注册表和一个生命周期工具注册为 utilities,同时注册一个生命周期钩子,在 ArchitecturePhase.BeforeUtilityInit 阶段触发 bootstrap.InitializeAsync()
  • 使用基于 Interlocked 的安装状态,防止同一个模块实例被安装到多个架构中。
  • 提供 StartHotReloadStopHotReload 的透传方法,使架构可以通过模块控制热重载。
GFramework.Game/Config/GameConfigModule.cs
扩展架构集成测试,覆盖基于模块的配置集成、初始化顺序以及模块复用约束。
  • ConsumerArchitecture 中直接使用 GameConfigBootstrap 的方式替换为使用 GameConfigModule,并通过 Registry/GetMonsterTable 辅助方法访问配置。
  • 在 SetUp/TearDown 中通过调用 GameContext.Clear() 重置 GlobalArchitectureContext,避免跨测试的架构泄漏。
  • 新增测试,确保配置模块在架构初始化期间完成初始化并对外暴露 registry/loader,同时验证模块状态标记。
  • 引入 ConfigAwareProbeUtility,在其 OnInit 中读取配置表,以断言配置在依赖的 utilities 初始化前已加载完成。
  • 新增 ModuleOnlyArchitecture,并添加测试:当将同一个 GameConfigModule 实例复用到多个架构时,会抛出 InvalidOperationException,且第一个架构仍能被正确初始化和释放。
  • 新增辅助方法 CreateModule,用于在测试中构建配置好的 GameConfigModule
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
更新中文配置系统文档,推荐在 Architecture 宿主中使用 GameConfigModule,并补充生命周期和热重载用法。
  • 在运行时组件概览中,将 GameConfigModuleYamlConfigLoaderConfigRegistryGameConfigBootstrap 一并提及。
  • 将文档中在 Architecture.OnInitialize/DestroyAsync 中手动接线 GameConfigBootstrap 的示例替换为基于 GameConfigModuleInstallModule 示例。
  • 更新推荐集成顺序:构造并安装 GameConfigModule,依赖 BeforeUtilityInit 完成首次加载,并将释放工作交给模块/utility 生命周期处理。
  • 解释基于模块集成的好处(注册表注册时机、加载阶段、释放行为),并澄清 GameConfigBootstrap 仍然适合非 Architecture 宿主场景。
  • 调整热重载示例,展示在 Architecture 场景中使用 GameConfigModule.StartHotReload,以及在非 Architecture 场景中使用 GameConfigBootstrap.StartHotReload 的方式。
docs/zh-CN/game/config-system.md

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

Original review guide in English

Reviewer's Guide

Introduces GameConfigModule as the official configuration integration entry for Architecture-based hosts, wires it into the architecture lifecycle via a module and lifecycle hook, adds integration tests to validate initialization order and module reuse protection, and updates the Chinese documentation to recommend the new module-based integration pattern.

Sequence diagram for Architecture initialization with GameConfigModule

sequenceDiagram
    participant Architecture as GameArchitecture
    participant Module as GameConfigModule
    participant Lifecycle as ArchitectureLifecycle
    participant Hook as BootstrapInitializationHook
    participant Bootstrap as GameConfigBootstrap
    participant Probe as ConfigAwareProbeUtility
    participant Registry as IConfigRegistry
    participant MonsterTable as MonsterTable

    Architecture->>Module: new GameConfigModule(options)
    Architecture->>Architecture: InstallModule(Module)
    Architecture->>Module: Install(this)
    Module->>Architecture: RegisterUtility(Registry)
    Module->>Architecture: RegisterUtility(ModuleBootstrapLifetimeUtility)
    Module->>Architecture: RegisterLifecycleHook(Hook)

    Architecture->>Lifecycle: InitializeAsync()

    Note over Lifecycle,Hook: BeforeUtilityInit phase
    Lifecycle->>Hook: OnPhase(BeforeUtilityInit, Architecture)
    Hook->>Bootstrap: InitializeAsync()
    Bootstrap-->>Hook: Config tables loaded

    Note over Lifecycle,Architecture: Utility initialization phase
    Lifecycle->>Architecture: Initialize utilities
    Architecture->>Probe: RegisterUtility(Probe)
    Architecture->>Probe: OnInit()
    Probe->>Registry: GetMonsterTable()
    Registry-->>Probe: MonsterTable
    Probe->>MonsterTable: Get(1)
    MonsterTable-->>Probe: Monster row
    Probe->>MonsterTable: FindByFaction("dungeon")
    MonsterTable-->>Probe: Monsters in dungeon faction
    Probe-->>Architecture: InitializedWithLoadedConfig = true

    Note over Architecture,Module: Destruction phase
    Architecture->>Architecture: DestroyAsync()
    Architecture->>ModuleBootstrapLifetimeUtility: OnDestroy()
    ModuleBootstrapLifetimeUtility->>Bootstrap: Dispose()
    Bootstrap-->>ModuleBootstrapLifetimeUtility: Hot reload stopped, resources freed
Loading

Class diagram for GameConfigModule and related lifecycle types

classDiagram
    class GameConfigModule {
        - GameConfigBootstrap _bootstrap
        - ModuleBootstrapLifetimeUtility _lifetimeUtility
        - int _installState
        + GameConfigModule(GameConfigBootstrapOptions options)
        + IConfigRegistry Registry
        + bool IsInitialized
        + bool IsHotReloadEnabled
        + YamlConfigLoader Loader
        + void Install(IArchitecture architecture)
        + void StartHotReload(YamlConfigHotReloadOptions options)
        + void StopHotReload()
    }

    class GameConfigBootstrap {
        + IConfigRegistry Registry
        + bool IsInitialized
        + bool IsHotReloadEnabled
        + YamlConfigLoader Loader
        + ValueTask InitializeAsync()
        + void StartHotReload(YamlConfigHotReloadOptions options)
        + void StopHotReload()
        + void Dispose()
    }

    class ModuleBootstrapLifetimeUtility {
        + ModuleBootstrapLifetimeUtility(GameConfigBootstrap bootstrap)
        + void OnInit()
        + void OnDestroy()
    }

    class BootstrapInitializationHook {
        + BootstrapInitializationHook(GameConfigBootstrap bootstrap)
        + void OnPhase(ArchitecturePhase phase, IArchitecture architecture)
    }

    class IArchitectureModule {
        <<interface>>
        + void Install(IArchitecture architecture)
    }

    class IArchitecture {
        <<interface>>
        + void RegisterUtility(object utility)
        + void RegisterLifecycleHook(IArchitectureLifecycleHook hook)
    }

    class IArchitectureLifecycleHook {
        <<interface>>
        + void OnPhase(ArchitecturePhase phase, IArchitecture architecture)
    }

    class AbstractContextUtility {
        <<abstract>>
        + void OnInit()
        + void OnDestroy()
    }

    class ArchitecturePhase {
        <<enumeration>>
        BeforeUtilityInit
        OtherPhases
    }

    class IConfigRegistry {
        <<interface>>
    }

    class YamlConfigLoader {
    }

    class YamlConfigHotReloadOptions {
    }

    class GameConfigBootstrapOptions {
    }

    GameConfigModule ..|> IArchitectureModule
    GameConfigModule o-- GameConfigBootstrap
    GameConfigModule o-- ModuleBootstrapLifetimeUtility
    GameConfigModule ..> BootstrapInitializationHook
    GameConfigModule ..> IArchitecture
    GameConfigModule ..> YamlConfigHotReloadOptions
    GameConfigModule ..> GameConfigBootstrapOptions
    GameConfigModule ..> IConfigRegistry
    GameConfigModule ..> YamlConfigLoader

    ModuleBootstrapLifetimeUtility ..|> AbstractContextUtility
    BootstrapInitializationHook ..|> IArchitectureLifecycleHook

    BootstrapInitializationHook ..> GameConfigBootstrap
    ModuleBootstrapLifetimeUtility ..> GameConfigBootstrap

    IArchitectureLifecycleHook ..> ArchitecturePhase
    IArchitectureLifecycleHook ..> IArchitecture

    IArchitecture ..> IConfigRegistry
    IArchitecture ..> AbstractContextUtility
Loading

File-Level Changes

Change Details Files
Add GameConfigModule to integrate GameConfigBootstrap into Architecture lifecycle with module semantics, hot-reload control, and single-install protection.
  • Wrap GameConfigBootstrap inside a sealed GameConfigModule implementing IArchitectureModule.
  • Expose Registry, initialization/hot-reload state, and Loader from the underlying bootstrap for consumers.
  • Register config registry and a lifetime utility as utilities and a lifecycle hook that triggers bootstrap.InitializeAsync() at ArchitecturePhase.BeforeUtilityInit.
  • Guard against installing the same module instance into multiple architectures using an interlocked install state.
  • Provide StartHotReload and StopHotReload pass-throughs so architectures can control hot reload via the module.
GFramework.Game/Config/GameConfigModule.cs
Extend architecture integration tests to cover module-based config integration, initialization ordering, and module reuse constraints.
  • Replace direct GameConfigBootstrap usage in ConsumerArchitecture with GameConfigModule and use Registry/GetMonsterTable helpers.
  • Add SetUp/TearDown ResetGlobalArchitectureContext using GameContext.Clear() to avoid cross-test architecture leakage.
  • Add test ensuring config module initializes and exposes registry/loader during architecture initialization and validates module flags.
  • Introduce ConfigAwareProbeUtility that reads config tables during its OnInit to assert config loads before dependent utilities initialize.
  • Add ModuleOnlyArchitecture and a test that reusing the same GameConfigModule instance across architectures throws InvalidOperationException and leaves first architecture properly initialized and disposed.
  • Add helper CreateModule to build a configured GameConfigModule for tests.
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
Update Chinese configuration system documentation to recommend using GameConfigModule for Architecture hosts and to document lifecycle and hot-reload usage.
  • Mention GameConfigModule alongside YamlConfigLoader, ConfigRegistry, and GameConfigBootstrap in the overview of provided runtime components.
  • Replace manual GameConfigBootstrap wiring example in Architecture.OnInitialize/DestroyAsync with a GameConfigModule-based InstallModule example.
  • Update recommended integration order to construct and install GameConfigModule, rely on BeforeUtilityInit for first load, and defer disposal to the module/utility lifecycle.
  • Explain the benefits of module-based integration (registry registration timing, load phase, and disposal behavior) and clarify that GameConfigBootstrap remains appropriate for non-Architecture hosts.
  • Adjust hot-reload examples to show using GameConfigModule.StartHotReload in Architecture scenarios and GameConfigBootstrap.StartHotReload for non-Architecture usage.
docs/zh-CN/game/config-system.md

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 - 我在这里给出了一些总体反馈:

  • BootstrapInitializationHook.OnPhase 中,你通过 bootstrap.InitializeAsync().GetAwaiter().GetResult() 进行同步阻塞,如果异步路径捕获了上下文或者变慢,就有造成死锁或长时间停顿的风险;建议要么确保 InitializeAsync 始终使用 ConfigureAwait(false) 且执行时间有良好边界,要么引入一个对异步友好的生命周期路径(或在 Install 阶段进行预初始化),从而避免阻塞架构的生命周期线程。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
-`BootstrapInitializationHook.OnPhase` 中,你通过 `bootstrap.InitializeAsync().GetAwaiter().GetResult()` 进行同步阻塞,如果异步路径捕获了上下文或者变慢,就有造成死锁或长时间停顿的风险;建议要么确保 `InitializeAsync` 始终使用 `ConfigureAwait(false)` 且执行时间有良好边界,要么引入一个对异步友好的生命周期路径(或在 `Install` 阶段进行预初始化),从而避免阻塞架构的生命周期线程。

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

Hey - I've left some high level feedback:

  • In BootstrapInitializationHook.OnPhase you synchronously block on bootstrap.InitializeAsync().GetAwaiter().GetResult(), which risks deadlocks or long stalls if the async path ever captures a context or becomes slower; consider either ensuring InitializeAsync is always ConfigureAwait(false) and well-bounded, or introducing an async-friendly lifecycle path (or pre‑initialization during Install) to avoid blocking the architecture’s lifecycle thread.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `BootstrapInitializationHook.OnPhase` you synchronously block on `bootstrap.InitializeAsync().GetAwaiter().GetResult()`, which risks deadlocks or long stalls if the async path ever captures a context or becomes slower; consider either ensuring `InitializeAsync` is always `ConfigureAwait(false)` and well-bounded, or introducing an async-friendly lifecycle path (or pre‑initialization during `Install`) to avoid blocking the architecture’s lifecycle thread.

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.

@greptile-apps

greptile-apps Bot commented Apr 9, 2026

Copy link
Copy Markdown

Greptile Summary

This PR introduces GameConfigModule as the official Architecture-hosted entry point for the GFramework configuration system, and resolves a previously flagged sync-over-async deadlock risk by adding ConfigureAwait(false) throughout the entire async loading chain (YamlConfigLoader, YamlConfigSchemaValidator, GameConfigBootstrap).

Key changes:

  • GameConfigModule wraps GameConfigBootstrap behind a clean install/lifecycle interface, registering IConfigRegistry as an architecture utility and scheduling the first config load via a BeforeUtilityInit lifecycle hook — ensuring config is available before any utility OnInit() runs.
  • A thread-safe install state machine (NotInstalled → Installing → Consumed) prevents concurrent double-install and correctly marks the module as consumed (even on partial failure) so callers know to create a fresh instance rather than retry.
  • ConfigureAwait(false) has been added to every await inside the async loading chain, directly addressing the prior review concern that a SynchronizationContext-blocked caller could deadlock.
  • A NonPumpingSynchronizationContext regression test validates the deadlock fix end-to-end: if any continuation accidentally captures the blocking sync context, it is silently dropped and the test fails by timeout.
  • Four new integration tests cover: normal module initialization, config-available-before-utility-init ordering guarantee, rejection of same-module-instance reuse across architectures, and late-installation rejection without consuming the module instance.
  • Documentation updated to recommend GameConfigModule as the preferred Architecture integration path, with lifecycle guidance and hot-reload comparison.

Confidence Score: 4/5

PR is safe to merge; all previously flagged concerns (deadlock, dangling hook, naming) have been addressed with both code and test coverage.

All prior P0/P1 review concerns are resolved: ConfigureAwait(false) is now applied throughout the entire async chain, the registration order (utilities before hook) eliminates the dangling-hook scenario, and a NonPumpingSynchronizationContext regression test validates the fix end-to-end. Only a single P2 style nit remains (null guard pattern in a private test class), which does not block merge.

GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs — minor null-guard style inconsistency in ConsumerArchitecture constructor; all other files are clean.

Vulnerabilities

No security concerns identified. The ConfigureAwait(false) changes are purely a threading fix. GameConfigModule does not accept user-controlled input, and file-system access is delegated to the existing YamlConfigLoader which is unchanged in behaviour.

Important Files Changed

Filename Overview
GFramework.Game/Config/GameConfigModule.cs New module correctly wires GameConfigBootstrap into the Architecture lifecycle via a BeforeUtilityInit hook; the three-state CAS install guard is sound and the registration order (utilities first, then hook) means partial install failures cannot leave a dangling hook.
GFramework.Game/Config/GameConfigBootstrap.cs Added ConfigureAwait(false) to LoadAsync call and updated XML docs to document the threading contract required by the sync bridge in GameConfigModule; no behavioral changes otherwise.
GFramework.Game/Config/YamlConfigLoader.cs ConfigureAwait(false) added to every await in LoadAsync, ReloadTableAsync, and the hot-reload debounce loop; these are the exact continuations that were missing the directive and could deadlock through the sync bridge.
GFramework.Game/Config/YamlConfigSchemaValidator.cs Single ConfigureAwait(false) addition to the File.ReadAllTextAsync call in LoadAsync; minimal and correct.
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs Four new integration tests with comprehensive lifecycle scenarios and a NonPumpingSynchronizationContext deadlock regression test; minor: ConsumerArchitecture uses explicit null-check instead of ArgumentNullException.ThrowIfNull, inconsistent with the rest of the PR.
docs/zh-CN/game/config-system.md Documentation accurately updated to recommend GameConfigModule as the preferred Architecture integration path and removes the outdated manual bootstrap template.

Sequence Diagram

sequenceDiagram
    participant A as Architecture
    participant M as GameConfigModule
    participant BS as GameConfigBootstrap
    participant Hook as BootstrapInitializationHook
    participant LU as ModuleBootstrapLifetimeUtility
    participant R as IConfigRegistry

    Note over A,R: OnInitialize() → InstallModule(module)
    A->>M: Install(architecture)
    M->>M: ValidateInstallationPhase (Phase == None)
    M->>M: CAS NotInstalled→Installing
    M->>A: RegisterUtility(Registry)
    A-->>R: registry registered as utility
    M->>A: RegisterUtility(lifetimeUtility)
    M->>A: RegisterLifecycleHook(BootstrapInitializationHook)
    M->>M: Volatile.Write → Consumed

    Note over A,R: Architecture.InitializeAsync() begins
    A->>Hook: OnPhase(BeforeUtilityInit, architecture)
    Hook->>BS: InitializeAsync().ConfigureAwait(false).GetAwaiter().GetResult()
    BS->>BS: YamlConfigLoader.LoadAsync (all awaits ConfigureAwait(false))
    BS-->>R: tables loaded into registry
    BS-->>Hook: (completed)

    Note over A,R: Utility OnInit() — config already loaded
    A->>LU: OnInit() — no-op

    Note over A,R: Architecture.DestroyAsync()
    A->>LU: OnDestroy()
    LU->>BS: Dispose()
    BS->>BS: StopHotReload() + release handles
Loading

Reviews (4): Last reviewed commit: "feat(config): 添加架构配置集成测试和模块实现" | Re-trigger Greptile

Comment thread GFramework.Game/Config/GameConfigModule.cs Outdated
Comment thread GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs Outdated

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/zh-CN/game/config-system.md (1)

436-440: ⚠️ Potential issue | 🟡 Minor

这里的异步接入说明又把读者带回旧的 bootstrap 路径了。

上面的模板已经切到 _configModule,但这一段仍然让读者去 await _configBootstrap.InitializeAsync()。按当前示例,这个字段并不存在,也会让人误解为 GameConfigModule 场景下还需要手动驱动 bootstrap。建议把两条路径明确拆开:Architecture 宿主下由 await architecture.InitializeAsync() 驱动模块;只有不走模块化接入时,才直接 await bootstrap.InitializeAsync()

As per coding guidelines, "Keep code samples, package names, and command examples in documentation aligned with the current repository state" and "For integration-oriented features such as the AI-First config system, documentation MUST cover project directory layout and file conventions, required project or package wiring, minimal working usage example, and migration or compatibility notes when behavior changes".

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

In `@docs/zh-CN/game/config-system.md` around lines 436 - 440, The documentation
incorrectly points readers to await _configBootstrap.InitializeAsync() even
though the example uses _configModule; update the text to clearly split two
paths: when using Architecture/module integration, instruct to drive
initialization via await architecture.InitializeAsync() which will initialize
GameConfigModule/_configModule, and otherwise (non-modular fallback) show
awaiting bootstrap.InitializeAsync(); replace references to _configBootstrap in
the GameConfigModule example with the modular flow and add a brief note about
when the synchronous .GetAwaiter().GetResult() bridge is acceptable as described
originally.
🤖 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.Game/Config/GameConfigModule.cs`:
- Around line 79-87: Move the side-effect-free phase validation before flipping
_installState and performing any architecture registration, and/or ensure
_installState is rolled back on errors: check the installation phase early
(before calling architecture.RegisterUtility(Registry) and
RegisterUtility(_lifetimeUtility)) and then set Interlocked.Exchange(ref
_installState, 1); wrap the subsequent registrations (including
RegisterLifecycleHook(new BootstrapInitializationHook(_bootstrap))) in a
try/catch that resets _installState back to 0 on exception and rethrows so the
module and architecture are not left half-installed.

---

Outside diff comments:
In `@docs/zh-CN/game/config-system.md`:
- Around line 436-440: The documentation incorrectly points readers to await
_configBootstrap.InitializeAsync() even though the example uses _configModule;
update the text to clearly split two paths: when using Architecture/module
integration, instruct to drive initialization via await
architecture.InitializeAsync() which will initialize
GameConfigModule/_configModule, and otherwise (non-modular fallback) show
awaiting bootstrap.InitializeAsync(); replace references to _configBootstrap in
the GameConfigModule example with the modular flow and add a brief note about
when the synchronous .GetAwaiter().GetResult() bridge is acceptable as described
originally.
🪄 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: 195d6f53-a3e1-4cdf-863f-d8a2b4fd77c8

📥 Commits

Reviewing files that changed from the base of the PR and between 55a51fb and f290050.

📒 Files selected for processing (3)
  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
  • GFramework.Game/Config/GameConfigModule.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: Analyze (C#)
  • GitHub Check: Code Quality & Security
🧰 Additional context used
📓 Path-based instructions (4)
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,docs/zh-CN/**/*.md}

📄 CodeRabbit inference engine (AGENTS.md)

{README.md,docs/**/*.md,docs/zh-CN/**/*.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 in documentation aligned with the current repository state
Prefer documenting behavior and design intent in documentation, not only API surface
For integration-oriented features such as the AI-First config system, documentation MUST cover project directory layout and file conventions, required project or package wiring, minimal working usage example, and migration or compatibility notes when behavior changes

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
**/*.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> where applicable in C# code
XML documentation comments MUST explain intent, contract, and usage constraints instead of restating syntax
If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML comments
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, or generated code assumptions
Avoid obvious comments such as // increment i in C# code
Generated logic and source generator pipelines MUST explain what is generated, why it is generated, the 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 in C# code
Comments MUST NOT be trivial, redundant, or misleading; prefer explaining why and when, not just what
Missing required documentation is a coding standards violation in C# code
Do not rely on implicit imports in C# code; declare every required using explicitly
Write null-safe C# code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase ...

Files:

  • GFramework.Game/Config/GameConfigModule.cs
  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
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: CLAUDE.md:0-0
Timestamp: 2026-04-05T15:30:46.211Z
Learning: Use ArchitectureLifecycle, ArchitectureComponentRegistry, and ArchitectureModules as independent components to manage lifecycle, component registration, and module installation respectively
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to {README.md,docs/**/*.md,docs/zh-CN/**/*.md} : For integration-oriented features such as the AI-First config system, documentation MUST cover project directory layout and file conventions, required project or package wiring, minimal working usage example, and migration or compatibility notes when behavior changes

Applied to files:

  • docs/zh-CN/game/config-system.md
📚 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:

  • docs/zh-CN/game/config-system.md
📚 Learning: 2026-04-05T15:30:46.211Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-05T15:30:46.211Z
Learning: Use ArchitectureLifecycle, ArchitectureComponentRegistry, and ArchitectureModules as independent components to manage lifecycle, component registration, and module installation respectively

Applied to files:

  • docs/zh-CN/game/config-system.md
  • GFramework.Game/Config/GameConfigModule.cs
  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.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.Game/Config/GameConfigModule.cs
  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Reuse existing architecture test infrastructure when relevant: `ArchitectureTestsBase<T>`, `SyncTestArchitecture`, `AsyncTestArchitecture`

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Use the namespace pattern `GFramework.{Module}.{Feature}` with PascalCase segments in C#

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
🪛 LanguageTool
docs/zh-CN/game/config-system.md

[uncategorized] ~468-~468: 能愿动词不能成为‘把’字句、‘被’字句的谓语动词。应该是:"可把……开发"。
Context: ...薄封装,而不是替代底层 bootstrap。 ### 热重载模板 如果你希望把开发期热重载显式收敛为一个可选能力,在 Architecture 场景下可以直接保留上面示例中的 `_c...

(wa3)

🔇 Additional comments (1)
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs (1)

76-152: 这组集成测试把模块化入口的关键语义锁住了。

首载顺序、上下文暴露和“同实例不可跨架构复用”都覆盖到了,能很好地防住这次入口改造的回归。

Based on learnings, "Public API changes must be covered by unit or integration tests".

Comment thread GFramework.Game/Config/GameConfigModule.cs Outdated
- 实现 GameConfigBootstrap 启动帮助器,统一管理配置注册表、YAML加载器与热重载句柄
- 创建 GameConfigModule 配置模块,集成到 Architecture 生命周期中完成自动加载与资源回收
- 实现 YamlConfigLoader 基于文件目录的YAML配置加载器,支持批量加载与热重载功能
- 添加 ArchitectureConfigIntegrationTests 集成测试,验证模块安装、加载顺序与表访问
- 实现热重载防抖机制,支持开发期配置变更监听与增量更新
- 提供同步上下文桥接支持,避免Unity主线程或UI线程上的死锁问题

@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

🧹 Nitpick comments (1)
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs (1)

395-457: 这些测试架构更适合复用现有的 Architecture 测试基建。

这里新增了 3 个直接继承 Architecture 的测试专用类型,并配套引入了显式的 GameContext.Clear() 管理。若现有的 ArchitectureTestsBase<T>SyncTestArchitectureAsyncTestArchitecture 能承载相同场景,建议优先复用它们,减少样板代码和全局上下文管理分散。

Based on learnings:Applies to **/*.Tests.cs : Reuse existing architecture test infrastructure when relevant: ArchitectureTestsBase<T>, SyncTestArchitecture, AsyncTestArchitecture

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

In `@GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs` around
lines 395 - 457, Replace the three custom test architectures
(ConsumerArchitecture, ModuleOnlyArchitecture, ReadyOnlyArchitecture) and the
ad-hoc GameContext.Clear() management by reusing the existing test
infrastructure: derive your tests from ArchitectureTestsBase<T> (or
SyncTestArchitecture / AsyncTestArchitecture as appropriate) and implement the
same behaviors by providing T or overriding its setup hooks instead of new
Architecture subclasses; for example, move the config module installation and
probe utility registration into the base-test setup/override rather than
ConsumerArchitecture.OnInitialize, inject an external GameConfigModule via the
base test rather than ModuleOnlyArchitecture, and rely on the base test
lifecycle to reach the Ready phase instead of ReadyOnlyArchitecture, then remove
explicit calls to GameContext.Clear().
🤖 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.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs`:
- Around line 410-416: Add XML documentation comments for the newly-public
members ConfigModule, Registry, MonsterTable, and ProbeUtility (and the
ModuleOnlyArchitecture.ConfigModule/Registry variants) by adding /// <summary>
describing each member's purpose, /// <returns> for property return types where
helpful, and /// <remarks> that explicitly documents
lifecycle/registration/disposal and threading constraints (e.g., that these
properties expose module installation results, access the shared
IConfigRegistry, and are valid only during test lifecycle setup/teardown). Also
include /// <exception> notes if accessing these properties can throw when the
module is not installed or the registry is unavailable, and ensure the wording
follows repo conventions about registration and lifecycle semantics.
- Around line 160-185: The test
GameConfigBootstrapShouldSupportSynchronousBridgeOnBlockingSynchronizationContext
currently calls GameConfigBootstrap.InitializeAsync directly and doesn't
exercise the real bridge path; change the test to run the full architecture
lifecycle inside the blocking SynchronizationContext by invoking
ConsumerArchitecture.InitializeAsync (or calling InstallModule to register the
GameConfigModule and then calling ConsumerArchitecture.InitializeAsync) so that
GameConfigModule.BootstrapInitializationHook.OnPhase (triggered at
ArchitecturePhase.BeforeUtilityInit) runs under the blocked context; ensure
assertions still validate bootstrap.IsInitialized and monster table contents and
clean up bootstrap/architecture after the run.

---

Nitpick comments:
In `@GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs`:
- Around line 395-457: Replace the three custom test architectures
(ConsumerArchitecture, ModuleOnlyArchitecture, ReadyOnlyArchitecture) and the
ad-hoc GameContext.Clear() management by reusing the existing test
infrastructure: derive your tests from ArchitectureTestsBase<T> (or
SyncTestArchitecture / AsyncTestArchitecture as appropriate) and implement the
same behaviors by providing T or overriding its setup hooks instead of new
Architecture subclasses; for example, move the config module installation and
probe utility registration into the base-test setup/override rather than
ConsumerArchitecture.OnInitialize, inject an external GameConfigModule via the
base test rather than ModuleOnlyArchitecture, and rely on the base test
lifecycle to reach the Ready phase instead of ReadyOnlyArchitecture, then remove
explicit calls to GameContext.Clear().
🪄 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: 5d8b7a2e-d4eb-4fd6-9f29-aa52588b80c5

📥 Commits

Reviewing files that changed from the base of the PR and between f290050 and 13c91c8.

📒 Files selected for processing (5)
  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
  • GFramework.Game/Config/GameConfigBootstrap.cs
  • GFramework.Game/Config/GameConfigModule.cs
  • GFramework.Game/Config/YamlConfigLoader.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
✅ Files skipped from review due to trivial changes (3)
  • GFramework.Game/Config/GameConfigBootstrap.cs
  • GFramework.Game/Config/YamlConfigSchemaValidator.cs
  • GFramework.Game/Config/YamlConfigLoader.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • GFramework.Game/Config/GameConfigModule.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> where applicable in C# code
XML documentation comments MUST explain intent, contract, and usage constraints instead of restating syntax
If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML comments
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, or generated code assumptions
Avoid obvious comments such as // increment i in C# code
Generated logic and source generator pipelines MUST explain what is generated, why it is generated, the 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 in C# code
Comments MUST NOT be trivial, redundant, or misleading; prefer explaining why and when, not just what
Missing required documentation is a coding standards violation in C# code
Do not rely on implicit imports in C# code; declare every required using explicitly
Write null-safe C# code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase ...

Files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Reuse existing architecture test infrastructure when relevant: `ArchitectureTestsBase<T>`, `SyncTestArchitecture`, `AsyncTestArchitecture`
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Reuse existing architecture test infrastructure when relevant: `ArchitectureTestsBase<T>`, `SyncTestArchitecture`, `AsyncTestArchitecture`

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Keep tests focused on observable behavior, not implementation trivia

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Naming must remain compatible with `scripts/validate-csharp-naming.sh`

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Follow standard C# naming: Types, methods, properties, events, constants in PascalCase; interfaces with `I` prefix; parameters and locals in camelCase; private fields in `_camelCase`

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.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.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Use the namespace pattern `GFramework.{Module}.{Feature}` with PascalCase segments in C#

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-05T15:30:46.211Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-05T15:30:46.211Z
Learning: Use ArchitectureLifecycle, ArchitectureComponentRegistry, and ArchitectureModules as independent components to manage lifecycle, component registration, and module installation respectively

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs

Comment thread GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs Outdated
Comment thread GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
- 为ConsumerArchitecture构造函数添加参数验证和功能说明文档
- 为ConfigModule属性添加配置模块获取方法的详细说明
- 为Registry属性添加配置注册表访问的生命周期状态说明
- 为MonsterTable属性添加怪物配置表读取的异常处理和使用约束
- 为ProbeUtility属性添加配置可见性探针的功能说明
- 为ModuleOnlyArchitecture类添加模块共享测试的相关文档
- 为配置模块和注册表属性添加生命周期状态和使用时机说明
Comment thread GFramework.Game/Config/GameConfigModule.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.

♻️ Duplicate comments (1)
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs (1)

155-185: ⚠️ Potential issue | 🟡 Minor

将阻塞上下文回归用例改为走 Architecture 模块桥接路径。

Line 160-170 目前直接调用 GameConfigBootstrap.InitializeAsync(),没有覆盖 GameConfigModule.BootstrapInitializationHook.OnPhase(ArchitecturePhase.BeforeUtilityInit) 的真实桥接链路。若后续钩子阶段或模块侧同步桥接回归,这个用例可能仍然通过。

🔧 建议修改
-[Test]
-public void GameConfigBootstrapShouldSupportSynchronousBridgeOnBlockingSynchronizationContext()
+[Test]
+public void GameConfigModuleShouldSupportSynchronousBridgeOnBlockingSynchronizationContext()
 {
     var rootPath = CreateTempConfigRoot();
-    GameConfigBootstrap? bootstrap = null;
+    ConsumerArchitecture? architecture = null;
     try
     {
-        bootstrap = CreateBootstrap(rootPath);
+        architecture = new ConsumerArchitecture(rootPath);

         RunBlockingOnSynchronizationContext(
-            () => bootstrap.InitializeAsync(),
+            () => architecture.InitializeAsync(),
             TimeSpan.FromSeconds(5));

-        var monsterTable = bootstrap.Registry.GetMonsterTable();
+        var monsterTable = architecture.Registry.GetMonsterTable();
         Assert.Multiple(() =>
         {
-            Assert.That(bootstrap.IsInitialized, Is.True);
+            Assert.That(architecture.ConfigModule.IsInitialized, Is.True);
             Assert.That(monsterTable.Get(1).Name, Is.EqualTo("Slime"));
             Assert.That(monsterTable.FindByFaction("dungeon").Count(), Is.EqualTo(2));
         });
     }
     finally
     {
-        bootstrap?.Dispose();
+        if (architecture is not null)
+        {
+            architecture.DestroyAsync().GetAwaiter().GetResult();
+        }
         DeleteDirectoryIfExists(rootPath);
     }
 }

Based on learnings:Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it;Applies to **/*.Tests.cs : Keep tests focused on observable behavior, not implementation trivia

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

In `@GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs` around
lines 155 - 185, The test should exercise the Architecture module bridge instead
of calling GameConfigBootstrap.InitializeAsync() directly: replace the lambda
passed to RunBlockingOnSynchronizationContext so it drives the initialization
through the Architecture bridge (e.g. register/use GameConfigModule and invoke
the bootstrap phase via the Architecture module entry such that
GameConfigModule.BootstrapInitializationHook.OnPhase(ArchitecturePhase.BeforeUtilityInit)
is executed) rather than calling GameConfigBootstrap.InitializeAsync() directly;
ensure you still run this invocation inside RunBlockingOnSynchronizationContext
and assert using the same bootstrap.Registry and bootstrap.IsInitialized
afterwards.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs`:
- Around line 155-185: The test should exercise the Architecture module bridge
instead of calling GameConfigBootstrap.InitializeAsync() directly: replace the
lambda passed to RunBlockingOnSynchronizationContext so it drives the
initialization through the Architecture bridge (e.g. register/use
GameConfigModule and invoke the bootstrap phase via the Architecture module
entry such that
GameConfigModule.BootstrapInitializationHook.OnPhase(ArchitecturePhase.BeforeUtilityInit)
is executed) rather than calling GameConfigBootstrap.InitializeAsync() directly;
ensure you still run this invocation inside RunBlockingOnSynchronizationContext
and assert using the same bootstrap.Registry and bootstrap.IsInitialized
afterwards.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8178b1ba-8dcd-4bf1-a3bd-1517b38e4eaf

📥 Commits

Reviewing files that changed from the base of the PR and between 13c91c8 and eb7a8c7.

📒 Files selected for processing (1)
  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.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> where applicable in C# code
XML documentation comments MUST explain intent, contract, and usage constraints instead of restating syntax
If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML comments
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, or generated code assumptions
Avoid obvious comments such as // increment i in C# code
Generated logic and source generator pipelines MUST explain what is generated, why it is generated, the 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 in C# code
Comments MUST NOT be trivial, redundant, or misleading; prefer explaining why and when, not just what
Missing required documentation is a coding standards violation in C# code
Do not rely on implicit imports in C# code; declare every required using explicitly
Write null-safe C# code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase ...

Files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
🧠 Learnings (19)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
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-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Reuse existing architecture test infrastructure when relevant: `ArchitectureTestsBase<T>`, `SyncTestArchitecture`, `AsyncTestArchitecture`

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Keep tests focused on observable behavior, not implementation trivia

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Naming must remain compatible with `scripts/validate-csharp-naming.sh`

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Follow standard C# naming: Types, methods, properties, events, constants in PascalCase; interfaces with `I` prefix; parameters and locals in camelCase; private fields in `_camelCase`

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Any change to public API, lifecycle semantics, module behavior, or extension points MUST update the related XML docs in C#

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : All public, protected, and internal types and members MUST include XML documentation comments (`///`) with `<summary>`, `<param>`, `<returns>`, `<exception>`, and `<remarks>` where applicable in C# code

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML comments

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, or generated code assumptions

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : XML documentation comments MUST explain intent, contract, and usage constraints instead of restating syntax

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Missing required documentation is a coding standards violation in C# code

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : If a framework abstraction changes meaning or intended usage, update the explanatory comments in C# code as part of the same change

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling in C# code

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to {README.md,docs/**/*.md,docs/zh-CN/**/*.md} : For integration-oriented features such as the AI-First config system, documentation MUST cover project directory layout and file conventions, required project or package wiring, minimal working usage example, and migration or compatibility notes when behavior changes

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.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.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Use the namespace pattern `GFramework.{Module}.{Feature}` with PascalCase segments in C#

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-05T15:30:46.211Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-05T15:30:46.211Z
Learning: Use ArchitectureLifecycle, ArchitectureComponentRegistry, and ArchitectureModules as independent components to manage lifecycle, component registration, and module installation respectively

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
🔇 Additional comments (2)
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs (2)

23-31: [SetUp]/[TearDown] 统一清理 GameContext 很好。

这能有效避免测试之间的全局架构上下文串扰,提升集成测试稳定性。


415-452: 公开成员的生命周期/可用性 XML 文档补充得很到位。

ConfigModuleRegistryMonsterTableProbeUtility 的注释清晰说明了初始化阶段与使用约束,可读性和维护性明显提升。

- 实现了 ArchitectureConfigIntegrationTests 测试类,验证配置模块在架构场景下的完整链路
- 添加了 GameConfigModule 类,提供基于 Architecture 的配置模块接入入口
- 实现了配置模块的生命周期管理,包括首次加载和热重载支持
- 集成了 BootstrapInitializationHook 确保配置在 utility 初始化前完成加载
- 添加了模块复用限制和安装窗口验证机制
- 实现了架构销毁时的资源清理和生命周期钩子注册

@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.

🧹 Nitpick comments (1)
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs (1)

327-329: XML 注释缩进不一致。

第 328-329 行在 /// 前多了一个空格,与第 327 行不一致。

🛠️ 建议的修复
     /// <summary>
-     ///     创建一个使用配置模块的模块实例。
-     /// </summary>
+    ///     创建一个使用配置模块的模块实例。
+    /// </summary>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs` around
lines 327 - 329, The XML doc comment for the method summary has inconsistent
indentation: lines with "///     创建一个使用配置模块的模块实例。" have extra leading space on
the second and third lines; update the XML comment so all three '///' lines
align consistently (remove the extra space before '///' on the lines shown) for
the summary in ArchitectureConfigIntegrationTests (the triple-slash summary
block).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs`:
- Around line 327-329: The XML doc comment for the method summary has
inconsistent indentation: lines with "///     创建一个使用配置模块的模块实例。" have extra
leading space on the second and third lines; update the XML comment so all three
'///' lines align consistently (remove the extra space before '///' on the lines
shown) for the summary in ArchitectureConfigIntegrationTests (the triple-slash
summary block).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 81e4474e-ac5e-4bb6-88ae-a0ecb0353023

📥 Commits

Reviewing files that changed from the base of the PR and between eb7a8c7 and febf948.

📒 Files selected for processing (2)
  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
  • GFramework.Game/Config/GameConfigModule.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • GFramework.Game/Config/GameConfigModule.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: Analyze (C#)
  • GitHub Check: Code Quality & Security
  • GitHub Check: Build and Test
🧰 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> where applicable in C# code
XML documentation comments MUST explain intent, contract, and usage constraints instead of restating syntax
If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML comments
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, or generated code assumptions
Avoid obvious comments such as // increment i in C# code
Generated logic and source generator pipelines MUST explain what is generated, why it is generated, the 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 in C# code
Comments MUST NOT be trivial, redundant, or misleading; prefer explaining why and when, not just what
Missing required documentation is a coding standards violation in C# code
Do not rely on implicit imports in C# code; declare every required using explicitly
Write null-safe C# code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase ...

Files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
🧠 Learnings (18)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
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-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Reuse existing architecture test infrastructure when relevant: `ArchitectureTestsBase<T>`, `SyncTestArchitecture`, `AsyncTestArchitecture`

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Keep tests focused on observable behavior, not implementation trivia

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Naming must remain compatible with `scripts/validate-csharp-naming.sh`

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Follow standard C# naming: Types, methods, properties, events, constants in PascalCase; interfaces with `I` prefix; parameters and locals in camelCase; private fields in `_camelCase`

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Any change to public API, lifecycle semantics, module behavior, or extension points MUST update the related XML docs in C#

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : All public, protected, and internal types and members MUST include XML documentation comments (`///`) with `<summary>`, `<param>`, `<returns>`, `<exception>`, and `<remarks>` where applicable in C# code

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML comments

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds, compatibility constraints, edge cases, registration order, lifecycle sequencing, or generated code assumptions

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Missing required documentation is a coding standards violation in C# code

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : XML documentation comments MUST explain intent, contract, and usage constraints instead of restating syntax

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : If a framework abstraction changes meaning or intended usage, update the explanatory comments in C# code as part of the same change

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to **/*.cs : Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling in C# code

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-06T10:00:34.101Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-06T10:00:34.101Z
Learning: Applies to {README.md,docs/**/*.md,docs/zh-CN/**/*.md} : For integration-oriented features such as the AI-First config system, documentation MUST cover project directory layout and file conventions, required project or package wiring, minimal working usage example, and migration or compatibility notes when behavior changes

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-05T15:30:46.211Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-05T15:30:46.211Z
Learning: Use ArchitectureLifecycle, ArchitectureComponentRegistry, and ArchitectureModules as independent components to manage lifecycle, component registration, and module installation respectively

Applied to files:

  • GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.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.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
🔇 Additional comments (6)
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs (6)

19-27: LGTM!

使用 [SetUp][TearDown] 双重清理全局架构上下文是合理的防御性设计,可以有效防止测试之间的状态泄漏。


151-187: 同步桥接回归测试覆盖了正确的架构路径。

此测试通过 NonPumpingSynchronizationContext 模拟会导致死锁的阻塞上下文,直接验证了 GameConfigModule.BootstrapInitializationHook.OnPhaseConfigureAwait(false).GetAwaiter().GetResult() 的正确性。如果异步链错误地捕获了原始上下文,测试将超时失败。


286-325: LGTM!

该辅助方法设计合理:在独立线程上设置不处理消息的同步上下文,然后同步阻塞等待异步操作完成。超时处理和异常捕获逻辑能够清晰地诊断死锁或初始化失败场景。


392-460: 测试架构设计清晰,XML 文档完整。

ConsumerArchitecture 现在正确暴露了 ConfigModuleRegistryMonsterTableProbeUtility,每个成员都有详细的 XML 文档说明其生命周期约束和使用场景。这符合仓库的文档规范。


506-539: 探针 utility 设计合理。

ConfigAwareProbeUtilityOnInit 阶段读取配置表,能够有效验证配置模块是否在 utility 初始化之前完成首次加载。如果加载顺序错误,GetMonsterTable() 调用将失败,测试会明确报告问题。


541-555: NonPumpingSynchronizationContext 实现正确。

Post 方法故意丢弃回调以模拟阻塞线程上下文。这是检测异步代码是否正确使用 ConfigureAwait(false) 的有效手段——如果 continuation 试图回到原始上下文,就会永久挂起并触发测试超时。

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