Refactor/cqrs dispatcher cache#246
Conversation
- 将通知、请求和流式处理的缓存从多个独立字典合并为统一的分发绑定结构 - 减少热路径上的重复字典查询操作,提升分发性能 - 重构请求分发绑定缓存,按响应类型分层避免值类型装箱开销 - 添加完整的调度绑定单元测试验证缓存行为正确性 - 简化通知和流式处理的缓存查找逻辑,统一调用模式
- 实现 CqrsHandlerRegistrar 类,支持扫描并注册 CQRS 请求/通知/流式处理器 - 添加程序集级源码生成注册器支持,减少冷启动反射开销 - 实现反射回退机制,在生成注册器不可用时进行类型扫描 - 添加进程级缓存机制,避免重复分析程序集元数据和类型加载 - 支持确定性的处理器注册顺序,按名称排序保证稳定性 - 实现类型加载容错机制,部分类型失败时保留其他处理器注册 - 添加完整的单元测试覆盖,验证各种注册场景和错误处理 - 实现日志记录功能,提供详细的注册过程诊断信息
- 新增 CQRS 核心概念、命令查询处理器实现指南 - 添加请求分发器、通知发布和管道行为使用说明 - 提供流式处理、验证行为等高级特性文档 - 完善源代码生成器模块介绍和配置说明 - 包含 Log、ContextAware、EnumExtensions 等生成器详细用法 - 添加 Godot 专用生成器如 GetNode、AutoUiPage 等使用指南 - 整理诊断信息、最佳实践和常见问题解答
📝 WalkthroughWalkthrough重构 CQRS 调度器与处理器注册器的缓存体系,合并多处独立缓存为基于弱引用的调度绑定缓存,引入程序集级与可加载类型的跨容器缓存;同时更新相关测试、文档与源生成器包装以反映模块拆分与命名空间变更。 Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Caller
participant Dispatcher as CqrsDispatcher
participant Cache as WeakKey/WeakTypePair Cache
participant Provider as ServiceProvider
participant Handler as Handler / Pipeline
Caller->>Dispatcher: Send/Publish/CreateStream(request)
Dispatcher->>Cache: GetOrAdd(key(s)) → binding
Note right of Cache: 创建或返回<br/>DispatchBinding(包含 HandlerType + Invoker(s))
Dispatcher->>Provider: Resolve(binding.HandlerType)
Provider->>Handler: 调用 via binding.Invoker / PipelineInvoker
Handler-->>Caller: response / stream / ack
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
README.md (1)
55-78:⚠️ Potential issue | 🟠 Major快速安装里漏了 CQRS 运行时包。
上面已经把
Cqrs列为建议按模块安装的一部分,但下面的命令示例只给了 Core / Game / Godot / Source Generators,没有GeWuYou.GFramework.Cqrs和GeWuYou.GFramework.Cqrs.Abstractions。用户照着 README 安装时会拿不到 CQRS runtime 本体。📄 建议补充
# 核心能力(推荐最小起步) dotnet add package GeWuYou.GFramework.Core dotnet add package GeWuYou.GFramework.Core.Abstractions +# CQRS +dotnet add package GeWuYou.GFramework.Cqrs +dotnet add package GeWuYou.GFramework.Cqrs.Abstractions + # 游戏扩展 dotnet add package GeWuYou.GFramework.Game dotnet add package GeWuYou.GFramework.Game.AbstractionsAs per coding guidelines,
{README.md,docs/**/*}在 behavior 或 setup steps 变化时必须同步更新相关 README 或 docs 页面。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@README.md` around lines 55 - 78, README 的“快速安装”示例遗漏了 CQRS 运行时包;在按模块安装示例中补上 GeWuYou.GFramework.Cqrs 和 GeWuYou.GFramework.Cqrs.Abstractions 两个包的安装命令(与已有 Core / Game / Godot / SourceGenerators 列表保持一致),并确保说明中提到的 “Cqrs” 模块在示例命令里可见以避免用户遗漏运行时依赖。
🤖 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/core/cqrs.md`:
- Line 74: The docs example imports the wrong namespace: replace the incorrect
using declaration "using GFramework.Cqrs.Cqrs.Command;" with the correct
namespace "using GFramework.Cqrs.Command;" so the handler example compiles and
matches the preceding command examples; update the import in the example block
that references the handler/command handler namespace.
In `@docs/zh-CN/source-generators/index.md`:
- Line 5: 在 GFramework 文档页缺少关于 GFramework.Cqrs.SourceGenerators(包名/工具标识
GeWuYou.GFramework.Cqrs.SourceGenerators)的接入说明;请在该页面补充一个小节,说明如何在项目中引用该 Source
Generator(NuGet 包/PackageReference),在 csproj 中启用/保留 Source
Generators(示例:PackageReference + LangVersion/GenerateAssemblyInfo 或需的 MSBuild
属性),展示最小可运行示例(如何把 handler 类放入项目,如何使用生成的 handler registry/工厂
并替代或与现有手动注册配合),并添加兼容性/迁移说明(解释 docs/zh-CN/core/cqrs.md
中“运行时优先使用生成注册器”的行为、如何移除旧的手动注册或保留回退)。另外在该页面目录/TOC 中新增该小节标题并在文末加入示例代码片段和链接到 CQRS
核心文档以便用户跟进。
In `@GFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.cs`:
- Around line 324-341: The test currently only verifies
GetCustomAttributes/GetType call counts; change it to assert observable behavior
across both containers by freezing each MicrosoftDiContainer after
CqrsTestRuntime.RegisterHandlers(firstContainer, generatedAssembly.Object) and
CqrsTestRuntime.RegisterHandlers(secondContainer, generatedAssembly.Object) and
then resolving the expected handler type
(ReflectionFallbackNotificationContainer.ReflectionOnlyHandlerType) from both
containers to ensure both completed registration; replace or augment the
generatedAssembly.Verify(...) call-count assertions with assertions that both
containers can resolve/activate the handler (mirroring the pattern used in
RegisterHandlers_Should_Cache_Loadable_Types_Across_Containers) so the test
fails if registration is skipped on the second container.
In `@GFramework.Cqrs/Internal/CqrsDispatcher.cs`:
- Around line 18-24: The static ConcurrentDictionary caches
NotificationDispatchBindings and StreamDispatchBindings in CqrsDispatcher will
prevent Type unloading and grow unbounded; replace the unbounded Type-keyed
ConcurrentDictionary usage with a weak-referenced cache (e.g., use
ConditionalWeakTable<Type, NotificationDispatchBinding> for
NotificationDispatchBindings and ConditionalWeakTable<(Type RequestType, Type
ResponseType), StreamDispatchBinding> equivalent for streams, or keep
ConcurrentDictionary but store WeakReference<Type> keys/values and add periodic
cleanup) so entries do not pin plugin/hotreload assemblies, update the
lookup/creation paths that reference NotificationDispatchBindings and
StreamDispatchBindings to use the weak cache API and to handle missing/collected
entries, and add XML/doc comments on CqrsDispatcher describing thread-safety
assumptions and failure modes for the cache.
In `@GFramework.Cqrs/Internal/CqrsHandlerRegistrar.cs`:
- Around line 14-25: The three static caches AssemblyMetadataCache,
RegistryActivationMetadataCache, and LoadableTypesCache hold strong references
to Assembly/Type and prevent unloading; change them to use weak-reference
semantics (e.g., replace
ConcurrentDictionary<Assembly,...>/ConcurrentDictionary<Type,...> with
ConditionalWeakTable<Assembly, AssemblyRegistrationMetadata> and
ConditionalWeakTable<Type, RegistryActivationMetadata> or an unload-aware
wrapper that stores WeakReference/ConditionalWeakTable entries) or add a
documented eviction API that removes entries for collectible assemblies, and
ensure thread-safety and disposal semantics are preserved for methods that
read/write these caches (update CqrsHandlerRegistrar methods that access those
static fields accordingly and add unit tests or comments documenting failure
modes).
---
Outside diff comments:
In `@README.md`:
- Around line 55-78: README 的“快速安装”示例遗漏了 CQRS 运行时包;在按模块安装示例中补上
GeWuYou.GFramework.Cqrs 和 GeWuYou.GFramework.Cqrs.Abstractions 两个包的安装命令(与已有 Core
/ Game / Godot / SourceGenerators 列表保持一致),并确保说明中提到的 “Cqrs”
模块在示例命令里可见以避免用户遗漏运行时依赖。
🪄 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: e5658e5a-9712-401d-86fc-634127eda52b
📒 Files selected for processing (8)
CLAUDE.mdGFramework.Cqrs.Tests/Cqrs/CqrsDispatcherCacheTests.csGFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.csGFramework.Cqrs/Internal/CqrsDispatcher.csGFramework.Cqrs/Internal/CqrsHandlerRegistrar.csREADME.mddocs/zh-CN/core/cqrs.mddocs/zh-CN/source-generators/index.md
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. 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 (3)
{README.md,docs/**/*}
📄 CodeRabbit inference engine (AGENTS.md)
{README.md,docs/**/*}: Update the relevantREADME.mdordocs/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 in documentation
Prefer documenting behavior and design intent, not only API surface in documentation
If an existing documentation page no longer reflects the current implementation, fixing the code without fixing the documentation is considered incomplete work
Files:
docs/zh-CN/source-generators/index.mddocs/zh-CN/core/cqrs.mdREADME.md
docs/zh-CN/**/*
📄 CodeRabbit inference engine (AGENTS.md)
docs/zh-CN/**/*: When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation indocs/zh-CN/in the same change
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
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/source-generators/index.mddocs/zh-CN/core/cqrs.md
**/*.cs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.cs: All public, protected, and internal types and members in C# MUST include XML documentation comments (///) using<summary>,<param>,<returns>,<exception>, and<remarks>tags where applicable
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 documentation
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds and edge cases, and registration order or lifecycle sequencing
Avoid obvious comments such as// increment i
Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and 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, if any
Comments MUST NOT be trivial, redundant, or misleading. Prefer explainingwhyandwhen, not justwhat
Code should remain understandable without requiring external context. Prefer slightly more explanation over too little for framework code
Missing required documentation is a coding standards violation. Code that does not meet the documentation rules is considered incomplete
Do not rely on implicit imports. Declare every requiredusingexplicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace patternGFramework.{Module}.{Feature}with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, and con...
Files:
GFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.csGFramework.Cqrs.Tests/Cqrs/CqrsDispatcherCacheTests.csGFramework.Cqrs/Internal/CqrsHandlerRegistrar.csGFramework.Cqrs/Internal/CqrsDispatcher.cs
🧠 Learnings (24)
📓 Common learnings
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T08:34:09.804Z
Learning: Use CQRS pattern for command and query separation with support for both synchronous and asynchronous execution
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T08:34:09.804Z
Learning: Implement IArchitecture as the top-level container responsible for lifecycle management, component registration, module installation, and unified service access
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T08:34:09.804Z
Learning: Separate Architecture lifecycle management into discrete phases (Init, Ready, Destroy) through ArchitectureLifecycle component
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T08:34:09.804Z
Learning: Use ArchitectureComponentRegistry for managing Model, System, and Utility registration and resolution
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T08:34:09.804Z
Learning: Use ArchitectureModules for managing module installation, service module integration, and extension point registration
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T08:34:09.804Z
Learning: Use EventBus for loose-coupled communication between modules with support for event publishing, subscription, priority, filters, and weak reference subscription
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T08:34:09.804Z
Learning: Use BindableProperty for responsive property models that drive UI or business layer updates through value change notifications
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T08:34:09.804Z
Learning: Use frame-driven coroutine system based on IYieldInstruction abstraction with scheduler support for waiting on time, events, and task completion
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T08:34:09.804Z
Learning: Use MicrosoftDiContainer for dependency injection, providing unified component registration and service resolution experience
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T08:34:09.804Z
Learning: Use IServiceModule pattern for registering built-in services (EventBus, CommandExecutor, QueryExecutor, etc.) with Architecture
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T08:34:09.804Z
Learning: Use CqrsHandlerRegistryGenerator to generate CQRS handler registrations for consuming assemblies; runtime prefers generated code, falls back to reflection scanning when unavailable
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : When generator behavior changes intentionally, update snapshots together with the implementation
Applied to files:
docs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.Tests.cs : Source generator changes MUST be covered by generator tests
Applied to files:
docs/zh-CN/source-generators/index.mdREADME.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to docs/zh-CN/**/* : 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/source-generators/index.mddocs/zh-CN/core/cqrs.mdREADME.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : Keep source generators deterministic and free of hidden environment or network dependencies
Applied to files:
docs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to docs/zh-CN/**/* : 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/source-generators/index.mddocs/zh-CN/core/cqrs.mdREADME.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
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:
docs/zh-CN/source-generators/index.mddocs/zh-CN/core/cqrs.md
📚 Learning: 2026-04-16T13:25:59.124Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 235
File: GFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.cs:1-3
Timestamp: 2026-04-16T13:25:59.124Z
Learning: In the GeWuYou/GFramework repository, the test project `GFramework.SourceGenerators.Tests` provides `global using NUnit.Framework;` via its `GlobalUsings.cs`. Do not flag missing `using NUnit.Framework;` directives in test files within this project, as the global using already covers it. The project-wide GlobalUsings.cs pattern is used broadly to supply common namespaces (including NUnit, System.IO, etc.) without per-file imports.
Applied to files:
docs/zh-CN/source-generators/index.mdCLAUDE.mdREADME.md
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: Source Generators must target netstandard2.1 and provide incremental Roslyn code generation capabilities
Applied to files:
docs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : Use the namespace pattern `GFramework.{Module}.{Feature}` with PascalCase segments
Applied to files:
docs/zh-CN/source-generators/index.mdCLAUDE.mdREADME.md
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: LoggerGenerator source generator with [Log] attribute must automatically generate log fields and logging helper methods
Applied to files:
docs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
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:
docs/zh-CN/core/cqrs.md
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: CqrsHandlerRegistryGenerator must generate CQRS handler registries for consuming assemblies with runtime prioritization of generated products and fallback to reflection scanning; non-default assemblies must be explicitly registered via RegisterCqrsHandlersFromAssembly or RegisterCqrsHandlersFromAssemblies
Applied to files:
GFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.csGFramework.Cqrs/Internal/CqrsHandlerRegistrar.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Public API changes must be covered by unit or integration tests
Applied to files:
GFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Keep tests focused on observable behavior, not implementation trivia
Applied to files:
GFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.csGFramework.Cqrs.Tests/Cqrs/CqrsDispatcherCacheTests.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.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.csGFramework.Cqrs.Tests/Cqrs/CqrsDispatcherCacheTests.csGFramework.Cqrs/Internal/CqrsHandlerRegistrar.csGFramework.Cqrs/Internal/CqrsDispatcher.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: Repository structure must organize code with clear separation: abstractions layers (netstandard2.1) for interfaces only, platform-independent implementation layers (net8.0+) for Core/Game/Ecs.Arch, engine integration layers for Godot, and source generator layers
Applied to files:
CLAUDE.mdREADME.md
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: Core / Game / Ecs.Arch implementations must target net8.0, net9.0, and net10.0 frameworks and remain platform-independent
Applied to files:
CLAUDE.md
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives
Applied to files:
CLAUDE.md
📚 Learning: 2026-04-06T12:45:47.739Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:47.739Z
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:
CLAUDE.mdREADME.md
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: Dependency injection must use MicrosoftDiContainer wrapping Microsoft.Extensions.DependencyInjection for unified component registration and service resolution
Applied to files:
GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherCacheTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to {README.md,docs/**/*} : Update the relevant `README.md` or `docs/` page when behavior, setup steps, architecture guidance, or user-facing examples change
Applied to files:
README.md
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: Document structure must place Chinese content in docs/zh-CN/ and follow reading order: root README.md, module README.md files, then docs/ topic documentation
Applied to files:
README.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : Preserve deterministic behavior in registries, lifecycle orchestration, and generated outputs
Applied to files:
GFramework.Cqrs/Internal/CqrsHandlerRegistrar.cs
🪛 LanguageTool
CLAUDE.md
[grammar] ~126-~126: Ensure spelling is correct
Context: .../ GFramework.Godot.SourceGenerators / GFramework.Cqrs.SourceGenerators 与相关 Abstractions/Comm...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
README.md
[grammar] ~35-~35: Ensure spelling is correct
Context: ... | | GFramework.Cqrs / GFramework.Cqrs.Abstractions | CQ...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[grammar] ~37-~37: Ensure spelling is correct
Context: ... | GFramework.Game.SourceGenerators / GFramework.Cqrs.SourceGenerators | 游戏配置 schema 与 CQRS ...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
- 新增 CQRS 核心概念、命令查询处理器实现指南 - 添加安装配置文档,包含各模块包说明与环境要求 - 实现源码生成器全面文档,涵盖 Log、Config Schema、CQRS Handler Registry 等特性 - 提供详细用法示例与最佳实践指导 - 包含常见问题解答与故障排查方案 - 添加 Godot 项目集成与性能优化相关内容
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
docs/zh-CN/core/cqrs.md (1)
86-107: 建议让 Handler 示例可独立复制运行。当前 Handler 代码块只展示了处理器命名空间;若用户单独复制该块,
CreatePlayerCommand类型来源不直观。建议在该代码块补上消息侧using(或在块内注释声明依赖前置示例),提升“最小示例”可复制性。📄 建议修改
-using GFramework.Cqrs.Cqrs.Command; +using GFramework.Cqrs.Command; +using GFramework.Cqrs.Cqrs.Command;As per coding guidelines,
docs/zh-CN/**/*的集成文档应提供可采用路径与最小工作示例,避免用户从源码反推接入方式。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/zh-CN/core/cqrs.md` around lines 86 - 107, 示例中的处理器 CreatePlayerCommandHandler 未显式声明 CreatePlayerCommand 的来源,导致复制粘贴无法独立运行;在示例顶部为处理器代码块补上缺失的 using 声明(例如 using GFramework.Cqrs.Command; 或使用 CreatePlayerCommand 所在的具体命名空间),或者在代码块内以单行注释说明依赖(例如 // requires CreatePlayerCommand defined in GFramework.Cqrs.Command),确保 CreatePlayerCommand 与任何相关消息类型在示例中可见并可直接复现。GFramework.Cqrs/Internal/CqrsDispatcher.cs (1)
390-417: 可选:为私有嵌套绑定类添加 XML 文档。
NotificationDispatchBinding、StreamDispatchBinding、RequestDispatchBinding<TResponse>作为私有嵌套类,虽不强制要求文档,但添加简要说明有助于后续维护者理解各绑定类的职责与字段语义。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@GFramework.Cqrs/Internal/CqrsDispatcher.cs` around lines 390 - 417, Add brief XML documentation comments to the three private nested binding classes to describe their purpose and the meaning of their properties: add a summary for NotificationDispatchBinding and its HandlerType and Invoker properties, for StreamDispatchBinding and its HandlerType and Invoker properties, and for RequestDispatchBinding<TResponse> describing its role plus the HandlerType, BehaviorType, RequestInvoker<TResponse> and RequestPipelineInvoker<TResponse> properties; keep comments concise (one-line summary + one-line remarks per property) so maintainers can quickly understand each binding's responsibilities.GFramework.Cqrs/Internal/WeakKeyCache.cs (1)
125-129: 每次调用GetOrAdd时存在闭包分配开销。第 128 行的 lambda
_ => valueFactory(primaryType, secondaryType)捕获了三个变量,即使缓存命中也会产生闭包分配。对于高频调用路径,可考虑将工厂委托移至调用点外部构造,或采用参数传递模式避免捕获。当前实现在正常 CQRS 工作负载下可接受,仅作为性能敏感场景的潜在优化方向。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@GFramework.Cqrs/Internal/WeakKeyCache.cs` around lines 125 - 129, 当前在 WeakKeyCache 的代码中对 secondaryEntries 调用 GetOrAdd 时使用了捕获 primaryType/secondaryType 的 lambda(_ => valueFactory(primaryType, secondaryType)),会导致闭包分配;改为先计算要插入的值(var created = valueFactory(primaryType, secondaryType))然后调用 secondaryEntries.GetOrAdd(secondaryType, created)(即使用接受 TValue 的 GetOrAdd 重载)以避免 lambda 捕获和闭包分配,修改涉及的符号为 WeakKeyCache、secondaryEntries、GetOrAdd 和 valueFactory。
🤖 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.Cqrs/Internal/WeakKeyCache.cs`:
- Around line 1-20: The file uses ConditionalWeakTable<TKey,TValue> in class
WeakKeyCache but is missing the System.Runtime.CompilerServices namespace
import; add a using for System.Runtime.CompilerServices at the top of the file
so the ConditionalWeakTable type referenced in WeakKeyCache<TKey,TValue> is
resolved during build.
---
Nitpick comments:
In `@docs/zh-CN/core/cqrs.md`:
- Around line 86-107: 示例中的处理器 CreatePlayerCommandHandler 未显式声明
CreatePlayerCommand 的来源,导致复制粘贴无法独立运行;在示例顶部为处理器代码块补上缺失的 using 声明(例如 using
GFramework.Cqrs.Command; 或使用 CreatePlayerCommand 所在的具体命名空间),或者在代码块内以单行注释说明依赖(例如
// requires CreatePlayerCommand defined in GFramework.Cqrs.Command),确保
CreatePlayerCommand 与任何相关消息类型在示例中可见并可直接复现。
In `@GFramework.Cqrs/Internal/CqrsDispatcher.cs`:
- Around line 390-417: Add brief XML documentation comments to the three private
nested binding classes to describe their purpose and the meaning of their
properties: add a summary for NotificationDispatchBinding and its HandlerType
and Invoker properties, for StreamDispatchBinding and its HandlerType and
Invoker properties, and for RequestDispatchBinding<TResponse> describing its
role plus the HandlerType, BehaviorType, RequestInvoker<TResponse> and
RequestPipelineInvoker<TResponse> properties; keep comments concise (one-line
summary + one-line remarks per property) so maintainers can quickly understand
each binding's responsibilities.
In `@GFramework.Cqrs/Internal/WeakKeyCache.cs`:
- Around line 125-129: 当前在 WeakKeyCache 的代码中对 secondaryEntries 调用 GetOrAdd
时使用了捕获 primaryType/secondaryType 的 lambda(_ => valueFactory(primaryType,
secondaryType)),会导致闭包分配;改为先计算要插入的值(var created = valueFactory(primaryType,
secondaryType))然后调用 secondaryEntries.GetOrAdd(secondaryType, created)(即使用接受
TValue 的 GetOrAdd 重载)以避免 lambda 捕获和闭包分配,修改涉及的符号为
WeakKeyCache、secondaryEntries、GetOrAdd 和 valueFactory。
🪄 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: 4e3916f2-ecd3-4135-8133-41a4de1554d9
📒 Files selected for processing (9)
GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherCacheTests.csGFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.csGFramework.Cqrs/Internal/CqrsDispatcher.csGFramework.Cqrs/Internal/CqrsHandlerRegistrar.csGFramework.Cqrs/Internal/WeakKeyCache.csREADME.mddocs/zh-CN/core/cqrs.mddocs/zh-CN/getting-started/installation.mddocs/zh-CN/source-generators/index.md
✅ Files skipped from review due to trivial changes (1)
- GFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.cs
🚧 Files skipped from review as they are similar to previous changes (2)
- GFramework.Cqrs/Internal/CqrsHandlerRegistrar.cs
- GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherCacheTests.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. 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 (3)
{README.md,docs/**/*}
📄 CodeRabbit inference engine (AGENTS.md)
{README.md,docs/**/*}: Update the relevantREADME.mdordocs/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 in documentation
Prefer documenting behavior and design intent, not only API surface in documentation
If an existing documentation page no longer reflects the current implementation, fixing the code without fixing the documentation is considered incomplete work
Files:
docs/zh-CN/getting-started/installation.mddocs/zh-CN/core/cqrs.mdREADME.mddocs/zh-CN/source-generators/index.md
docs/zh-CN/**/*
📄 CodeRabbit inference engine (AGENTS.md)
docs/zh-CN/**/*: When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation indocs/zh-CN/in the same change
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
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/getting-started/installation.mddocs/zh-CN/core/cqrs.mddocs/zh-CN/source-generators/index.md
**/*.cs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.cs: All public, protected, and internal types and members in C# MUST include XML documentation comments (///) using<summary>,<param>,<returns>,<exception>, and<remarks>tags where applicable
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 documentation
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds and edge cases, and registration order or lifecycle sequencing
Avoid obvious comments such as// increment i
Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and 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, if any
Comments MUST NOT be trivial, redundant, or misleading. Prefer explainingwhyandwhen, not justwhat
Code should remain understandable without requiring external context. Prefer slightly more explanation over too little for framework code
Missing required documentation is a coding standards violation. Code that does not meet the documentation rules is considered incomplete
Do not rely on implicit imports. Declare every requiredusingexplicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace patternGFramework.{Module}.{Feature}with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, and con...
Files:
GFramework.Cqrs/Internal/WeakKeyCache.csGFramework.Cqrs/Internal/CqrsDispatcher.cs
🧠 Learnings (21)
📓 Common learnings
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: All coding rules must be strictly followed as defined in AGENTS.md
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: Abstractions projects must contain only interfaces and contract definitions without any runtime implementation logic
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: Architecture implements four-layer structure: IArchitecture (lifecycle management), IContextAware (unified context access), IModel (data/state layer), ISystem (business logic layer), and IUtility (stateless utility layer)
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: ArchitectureLifecycle manages lifecycle phases (Init, Ready, Destroy) and fine-grained initialization/destruction stages for Utility, Model, System, service modules, and hooks
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: ArchitectureComponentRegistry manages registration and resolution of Model, System, and Utility components
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: ArchitectureModules manages module installation, service module integration, and extension point registration
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: IArchitectureContext and related Provider types must handle context propagation across components to enable unified access to architecture services without direct coupling to implementation details
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: Use CQRS pattern with unified 'Cqrs' naming entry point; historical 'Mediator' compatibility aliases have been removed from public API
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: EventBus should be type-safe and support event publishing, subscription, priorities, filters, and weak reference subscriptions for loose-coupling communication
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: BindableProperty should implement reactive property model for lightweight state synchronization driven by value change notifications
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: Coroutine system must be frame-driven, based on IYieldInstruction and scheduler abstractions, supporting common patterns like waiting for time, events, and task completion
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: Use MicrosoftDiContainer as the IoC container, wrapping Microsoft.Extensions.DependencyInjection for unified component registration and service resolution
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: IServiceModule pattern should be used for registering built-in services (EventBus, CommandExecutor, QueryExecutor, etc.) with Architecture, handling 'infrastructure capability assembly'
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: Module dependency graph must follow the specified constraints: Core.SourceGenerators depends on SourceGenerators.Common; Godot depends on Core and Game; Cqrs depends on Core.Abstractions; etc.
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: Documentation must be located in docs/ with Chinese content in docs/zh-CN/; documentation should cover installation, module capabilities, source generators, tutorials, best practices, and troubleshooting
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T09:42:24.173Z
Learning: Design framework through clear module boundaries, composable service registration, stable abstract contracts, and appropriate source code generation to enable long-term evolution
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to docs/zh-CN/**/* : 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/getting-started/installation.mddocs/zh-CN/core/cqrs.mdREADME.mddocs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to docs/zh-CN/**/* : 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/getting-started/installation.mddocs/zh-CN/core/cqrs.mdREADME.mddocs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to docs/zh-CN/**/* : 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
Applied to files:
docs/zh-CN/getting-started/installation.mddocs/zh-CN/core/cqrs.mddocs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T13:25:59.124Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 235
File: GFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.cs:1-3
Timestamp: 2026-04-16T13:25:59.124Z
Learning: In the GeWuYou/GFramework repository, the test project `GFramework.SourceGenerators.Tests` provides `global using NUnit.Framework;` via its `GlobalUsings.cs`. Do not flag missing `using NUnit.Framework;` directives in test files within this project, as the global using already covers it. The project-wide GlobalUsings.cs pattern is used broadly to supply common namespaces (including NUnit, System.IO, etc.) without per-file imports.
Applied to files:
docs/zh-CN/getting-started/installation.mdREADME.mddocs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : Use the namespace pattern `GFramework.{Module}.{Feature}` with PascalCase segments
Applied to files:
docs/zh-CN/getting-started/installation.mdREADME.mddocs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: Repository structure must organize code with clear separation: abstractions layers (netstandard2.1) for interfaces only, platform-independent implementation layers (net8.0+) for Core/Game/Ecs.Arch, engine integration layers for Godot, and source generator layers
Applied to files:
docs/zh-CN/getting-started/installation.mdREADME.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Reuse existing architecture test infrastructure when relevant: `ArchitectureTestsBase<T>`, `SyncTestArchitecture`, `AsyncTestArchitecture`
Applied to files:
docs/zh-CN/getting-started/installation.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 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.Cqrs/Internal/WeakKeyCache.csGFramework.Cqrs/Internal/CqrsDispatcher.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : When adding caching, pooling, or shared mutable state, document thread-safety assumptions and failure modes
Applied to files:
GFramework.Cqrs/Internal/CqrsDispatcher.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: CqrsHandlerRegistryGenerator must generate CQRS handler registries for consuming assemblies with runtime prioritization of generated products and fallback to reflection scanning; non-default assemblies must be explicitly registered via RegisterCqrsHandlersFromAssembly or RegisterCqrsHandlersFromAssemblies
Applied to files:
docs/zh-CN/core/cqrs.mddocs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: CQRS pattern must separate commands and queries with support for both synchronous and asynchronous execution using the unified Cqrs naming entry point
Applied to files:
docs/zh-CN/core/cqrs.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : When generator behavior changes intentionally, update snapshots together with the implementation
Applied to files:
README.mddocs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to {README.md,docs/**/*} : Update the relevant `README.md` or `docs/` page when behavior, setup steps, architecture guidance, or user-facing examples change
Applied to files:
README.md
📚 Learning: 2026-04-06T12:45:47.739Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:47.739Z
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:
README.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.Tests.cs : Source generator changes MUST be covered by generator tests
Applied to files:
README.mddocs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : Keep source generators deterministic and free of hidden environment or network dependencies
Applied to files:
docs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: Source Generators must target netstandard2.1 and provide incremental Roslyn code generation capabilities
Applied to files:
docs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
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:
docs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Applied to files:
docs/zh-CN/source-generators/index.md
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: LoggerGenerator source generator with [Log] attribute must automatically generate log fields and logging helper methods
Applied to files:
docs/zh-CN/source-generators/index.md
🪛 GitHub Check: Build and Test
GFramework.Cqrs/Internal/WeakKeyCache.cs
[failure] 20-20:
The type or namespace name 'ConditionalWeakTable<,>' could not be found (are you missing a using directive or an assembly reference?)
[failure] 20-20:
The type or namespace name 'ConditionalWeakTable<,>' could not be found (are you missing a using directive or an assembly reference?)
[failure] 20-20:
The type or namespace name 'ConditionalWeakTable<,>' could not be found (are you missing a using directive or an assembly reference?)
[failure] 20-20:
The type or namespace name 'ConditionalWeakTable<,>' could not be found (are you missing a using directive or an assembly reference?)
[failure] 20-20:
The type or namespace name 'ConditionalWeakTable<,>' could not be found (are you missing a using directive or an assembly reference?)
[failure] 20-20:
The type or namespace name 'ConditionalWeakTable<,>' could not be found (are you missing a using directive or an assembly reference?)
🪛 LanguageTool
docs/zh-CN/getting-started/installation.md
[grammar] ~14-~14: Ensure spelling is correct
Context: ...me | 命令/查询/通知分发与处理器注册 | | GeWuYou.GFramework.Cqrs.Abstractions | CQRS 抽象契约 | CQR...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[grammar] ~20-~20: Ensure spelling is correct
Context: ...器 | Godot 节点、UI、项目元数据生成 | | GeWuYou.GFramework.Cqrs.SourceGenerators | CQRS 源码生成器 | 处理器...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
README.md
[grammar] ~35-~35: Ensure spelling is correct
Context: ... | | GFramework.Cqrs / GFramework.Cqrs.Abstractions | CQ...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[grammar] ~37-~37: Ensure spelling is correct
Context: ... | GFramework.Game.SourceGenerators / GFramework.Cqrs.SourceGenerators | 游戏配置 schema 与 CQRS ...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
docs/zh-CN/source-generators/index.md
[uncategorized] ~176-~176: 您的意思是“"不"齐”?
Context: ...果你的项目已经使用 GFramework 架构层,请在现有 Core 依赖基础上补齐 CQRS runtime 与 generator: ```xml <Ite...
(BU)
[uncategorized] ~195-~195: 您的意思是“"不"走”?
Context: ...er registry;如果某个 handler 无法被生成代码直接引用,则自动补走定向反射回退。 ```csharp using GFramework.Cor...
(BU)
🔇 Additional comments (6)
docs/zh-CN/getting-started/installation.md (1)
33-35: 文档更新方向正确,安装与示例已对齐模块拆分。新增 CQRS runtime/abstractions 的安装方式,以及
OnInitialize/OnInit示例更新都很清晰,和当前实现一致,可直接指导接入。Also applies to: 72-74, 167-169, 174-187
docs/zh-CN/source-generators/index.md (1)
166-229: CQRS 生成器接入文档补充完整,覆盖面到位。这一段已经包含接入包、最小示例和迁移兼容说明,能有效支撑用户从反射路径迁移到生成注册表优先路径。
README.md (1)
28-38: README 与模块拆分后的实际形态保持一致,信息清晰。模块矩阵、安装命令和仓库结构三处同步更新到位,能明显减少新用户在选包和项目结构上的理解偏差。
Also applies to: 66-68, 114-126
GFramework.Cqrs/Internal/WeakKeyCache.cs (1)
31-51: 双检锁模式实现正确,线程安全性良好。
GetOrAdd方法使用Volatile.Read实现快速路径读取,锁内重新读取_entries引用以正确处理与Clear()的竞态,且在添加前校验工厂返回值非空。整体实现符合弱键缓存的设计意图。GFramework.Cqrs/Internal/CqrsDispatcher.cs (2)
18-30: 弱键缓存重构有效解决了类型卸载和无界增长问题。将原有
ConcurrentDictionary<Type, ...>替换为WeakKeyCache和WeakTypePairCache,确保插件或热重载程序集中的类型可被正常卸载。缓存注释清晰说明了失效后重新计算的行为,符合编码规范对缓存线程安全和失效模式文档化的要求。
349-388:RequestDispatchBindingBox类型擦除模式实现正确。抽象基类与泛型派生类的组合有效处理了响应类型的类型擦除问题。第 380-384 行的运行时类型检查确保类型安全,第 386 行的强制转换因前置检查而安全。此模式避免了值类型响应退化为
object桥接的性能损耗。
- 实现了完整的CQRS分发器,支持命令、查询、通知和流式处理 - 添加了弱键缓存机制确保程序集卸载安全 - 实现了管道行为支持,可添加日志、验证等横切关注点 - 提供了类型安全的请求分发和处理器注册功能 - 编写了详细的CQRS中文文档,涵盖基本用法和最佳实践 - 支持编译期生成处理器注册表优化启动性能
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
GFramework.Cqrs/Internal/WeakKeyCache.cs (1)
1-20:⚠️ Potential issue | 🔴 Critical补上
ConditionalWeakTable的命名空间导入。当前构建已经在 Line 20 报
ConditionalWeakTable<,>未解析;如果GlobalUsings.cs没有显式导入System.Runtime.CompilerServices,这里会持续编译失败。建议直接在文件头补using System.Runtime.CompilerServices;,不要把这个依赖留给隐式上下文。 Based on learnings, "In the GeWuYou/GFramework repository, C# files may omit explicitusing System*imports because the project-wideGlobalUsings.cs... supplies common namespaces", but that only applies when the namespace is actually provided.🔧 建议修改
+using System.Runtime.CompilerServices; + namespace GFramework.Cqrs.Internal;#!/bin/bash printf '%s\n' '--- GlobalUsings candidates ---' fd -i 'GlobalUsings.cs' -x sed -n '1,200p' {} printf '\n%s\n' '--- WeakKeyCache header ---' sed -n '1,40p' GFramework.Cqrs/Internal/WeakKeyCache.cs printf '\n%s\n' '--- ConditionalWeakTable / Runtime.CompilerServices references ---' rg -n --type=cs 'ConditionalWeakTable|System\.Runtime\.CompilerServices'🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@GFramework.Cqrs/Internal/WeakKeyCache.cs` around lines 1 - 20, The file defines and uses ConditionalWeakTable<TKey, TValue> inside WeakKeyCache<TKey, TValue> but omits the System.Runtime.CompilerServices namespace import, causing ConditionalWeakTable to be unresolved; add a top-level using System.Runtime.CompilerServices; to the file (above the namespace declaration) so ConditionalWeakTable and any related attributes resolve without relying on GlobalUsings.cs.
🤖 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.Cqrs/Internal/WeakKeyCache.cs`:
- Around line 22-30: The XML docs for the GetOrAdd methods do not state that the
valueFactory must not return null, while the implementations call ThrowIfNull on
the factory result; update the summary/remarks of both GetOrAdd overloads to
include the contract that valueFactory must produce a non-null value (and that a
returned null will cause an exception), referencing the method name GetOrAdd and
the behavior (ThrowIfNull) so callers know the factory's return cannot be null.
---
Duplicate comments:
In `@GFramework.Cqrs/Internal/WeakKeyCache.cs`:
- Around line 1-20: The file defines and uses ConditionalWeakTable<TKey, TValue>
inside WeakKeyCache<TKey, TValue> but omits the System.Runtime.CompilerServices
namespace import, causing ConditionalWeakTable to be unresolved; add a top-level
using System.Runtime.CompilerServices; to the file (above the namespace
declaration) so ConditionalWeakTable and any related attributes resolve without
relying on GlobalUsings.cs.
🪄 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: 783a3ad3-ffe1-48a9-922f-360a239063a0
📒 Files selected for processing (3)
GFramework.Cqrs/Internal/CqrsDispatcher.csGFramework.Cqrs/Internal/WeakKeyCache.csdocs/zh-CN/core/cqrs.md
✅ Files skipped from review due to trivial changes (1)
- docs/zh-CN/core/cqrs.md
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. 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 (AGENTS.md)
**/*.cs: All public, protected, and internal types and members in C# MUST include XML documentation comments (///) using<summary>,<param>,<returns>,<exception>, and<remarks>tags where applicable
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 documentation
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds and edge cases, and registration order or lifecycle sequencing
Avoid obvious comments such as// increment i
Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and 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, if any
Comments MUST NOT be trivial, redundant, or misleading. Prefer explainingwhyandwhen, not justwhat
Code should remain understandable without requiring external context. Prefer slightly more explanation over too little for framework code
Missing required documentation is a coding standards violation. Code that does not meet the documentation rules is considered incomplete
Do not rely on implicit imports. Declare every requiredusingexplicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace patternGFramework.{Module}.{Feature}with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, and con...
Files:
GFramework.Cqrs/Internal/CqrsDispatcher.csGFramework.Cqrs/Internal/WeakKeyCache.cs
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: All coding rules must be followed strictly as defined in AGENTS.md
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: Core / Game / Ecs.Arch implementation layers must be platform-agnostic and target net8.0;net9.0;net10.0
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: Godot integration layer must handle adaptation with nodes, scenes, and engine lifecycle integration
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: SourceGenerators projects must implement Roslyn incremental source generators and target netstandard2.0/netstandard2.1
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: Architecture implementation must use the four-layer structure: IArchitecture / IModel / ISystem / IUtility
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: IArchitecture must act as the top-level container responsible for lifecycle management, component registration, module installation, and unified service access
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: Architecture lifecycle must be orchestrated through three core phases: Init, Ready, and Destroy
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: ArchitectureLifecycle component must manage lifecycle phases, phase transitions, and lifecycle hooks
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: ArchitectureComponentRegistry must manage registration and resolution of Model, System, and Utility components
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: ArchitectureModules must manage module installation, service module integration, and extension point registration
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: IArchitectureContext and Provider types must propagate context capabilities between components without direct coupling to implementation details
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: CQRS pattern must separate commands and queries with support for both synchronous and asynchronous execution
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: EventBus must provide type-safe event publishing and subscription with support for priority, filters, and weak reference subscriptions
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: BindableProperty model must support reactive property changes that drive UI and business layer updates
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: Coroutine system must be frame-driven based on IYieldInstruction and scheduler abstractions, supporting patterns like wait time, events, and task completion
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: IoC container must use MicrosoftDiContainer wrapper around Microsoft.Extensions.DependencyInjection for unified component registration and service resolution
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: IServiceModule pattern must be used to register built-in services like EventBus, CommandExecutor, and QueryExecutor with Architecture
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: LoggerGenerator must automatically generate log fields and logging helper methods for classes marked with [Log] attribute
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: PriorityGenerator must generate priority comparison implementations for classes marked with [Priority] attribute
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: EnumExtensionsGenerator must generate enum extension capabilities for enums marked with [GenerateEnumExtensions] attribute
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: ContextAwareGenerator must automatically implement IContextAware boilerplate logic for classes marked with [ContextAware] attribute
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: CqrsHandlerRegistryGenerator must generate CQRS handler registrations for consuming assemblies, with runtime-generated registrations taking precedence over reflection fallback
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T10:13:00.847Z
Learning: Repository must separate abstractions from implementations across multiple projects: Abstractions projects (netstandard2.1) for interfaces, Core/Game/Ecs.Arch (net8.0+) for platform-agnostic implementations, and Godot for engine integration
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : When adding caching, pooling, or shared mutable state, document thread-safety assumptions and failure modes
Applied to files:
GFramework.Cqrs/Internal/CqrsDispatcher.csGFramework.Cqrs/Internal/WeakKeyCache.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.Cqrs/Internal/CqrsDispatcher.csGFramework.Cqrs/Internal/WeakKeyCache.cs
📚 Learning: 2026-04-16T13:25:59.124Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 235
File: GFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.cs:1-3
Timestamp: 2026-04-16T13:25:59.124Z
Learning: In the GeWuYou/GFramework repository, the test project `GFramework.SourceGenerators.Tests` provides `global using NUnit.Framework;` via its `GlobalUsings.cs`. Do not flag missing `using NUnit.Framework;` directives in test files within this project, as the global using already covers it. The project-wide GlobalUsings.cs pattern is used broadly to supply common namespaces (including NUnit, System.IO, etc.) without per-file imports.
Applied to files:
GFramework.Cqrs/Internal/WeakKeyCache.cs
🪛 GitHub Check: Build and Test
GFramework.Cqrs/Internal/WeakKeyCache.cs
[failure] 20-20:
The type or namespace name 'ConditionalWeakTable<,>' could not be found (are you missing a using directive or an assembly reference?)
[failure] 20-20:
The type or namespace name 'ConditionalWeakTable<,>' could not be found (are you missing a using directive or an assembly reference?)
[failure] 20-20:
The type or namespace name 'ConditionalWeakTable<,>' could not be found (are you missing a using directive or an assembly reference?)
[failure] 20-20:
The type or namespace name 'ConditionalWeakTable<,>' could not be found (are you missing a using directive or an assembly reference?)
[failure] 20-20:
The type or namespace name 'ConditionalWeakTable<,>' could not be found (are you missing a using directive or an assembly reference?)
[failure] 20-20:
The type or namespace name 'ConditionalWeakTable<,>' could not be found (are you missing a using directive or an assembly reference?)
🔇 Additional comments (1)
GFramework.Cqrs/Internal/CqrsDispatcher.cs (1)
161-217: binding 构造收敛得很干净。这里把服务类型、行为类型和强类型 invoker 一起封装进同一批 dispatch binding 后,调用点只剩“取 binding → 解析服务 → 执行”,比之前拆成多套缓存更容易保持一致,也更不容易再引入类型卸载问题。
- 为 GetOrAdd 方法添加 valueFactory 返回 null 时的异常说明 - 在 GlobalUsings 中添加 System.Runtime.CompilerServices 引用
- 在初始化方法中添加了针对GF_ContextRegistration_003警告的禁用指令 - 通过#pragma warning disable和#pragma warning restore临时禁用了特定警告 - 保持了原有的配置注册表获取和怪物表格数据读取逻辑 - 确保了测试代码的编译清洁性同时维持功能完整性
There was a problem hiding this comment.
🧹 Nitpick comments (1)
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs (1)
532-534: 请为GF_ContextRegistration_003抑制补充“原因注释”。当前抑制范围控制得很好,但缺少“为何必须抑制且为何安全”的说明,后续维护者较难判断是否可移除或扩展该抑制。
建议修改
+#pragma warning disable GF_ContextRegistration_003 // 测试故意在 OnInit 阶段读取 IConfigRegistry,用于验证配置模块在 Utility 初始化前已完成首载 var registry = this.GetUtility<IConfigRegistry>(); `#pragma` warning restore GF_ContextRegistration_003As per coding guidelines "When adding analyzers or suppressions, keep them minimal and justify them in code comments if the reason is not obvious".
🤖 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 532 - 534, Add an inline justification comment explaining why the GF_ContextRegistration_003 pragma is required and why it is safe to suppress here: locate the pragma around the call to GetUtility<IConfigRegistry>() in the ArchitectureConfigIntegrationTests class and immediately above the `#pragma` warning disable GF_ContextRegistration_003 add a brief sentence stating the specific reason (e.g., test helper uses non-standard context registration intentionally, validated by test setup) and that it is safe (e.g., covered by surrounding test fixtures or mocks), then preserve the existing `#pragma` restore GF_ContextRegistration_003; keep the comment concise and specific so future maintainers can evaluate removal.
🤖 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 532-534: Add an inline justification comment explaining why the
GF_ContextRegistration_003 pragma is required and why it is safe to suppress
here: locate the pragma around the call to GetUtility<IConfigRegistry>() in the
ArchitectureConfigIntegrationTests class and immediately above the `#pragma`
warning disable GF_ContextRegistration_003 add a brief sentence stating the
specific reason (e.g., test helper uses non-standard context registration
intentionally, validated by test setup) and that it is safe (e.g., covered by
surrounding test fixtures or mocks), then preserve the existing `#pragma` restore
GF_ContextRegistration_003; keep the comment concise and specific so future
maintainers can evaluate removal.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 52ca1ad9-7726-44ad-aecf-97bb1181a2d0
📒 Files selected for processing (3)
GFramework.Cqrs/GlobalUsings.csGFramework.Cqrs/Internal/WeakKeyCache.csGFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
✅ Files skipped from review due to trivial changes (1)
- GFramework.Cqrs/GlobalUsings.cs
🚧 Files skipped from review as they are similar to previous changes (1)
- GFramework.Cqrs/Internal/WeakKeyCache.cs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.cs: All public, protected, and internal types and members in C# MUST include XML documentation comments (///) using<summary>,<param>,<returns>,<exception>, and<remarks>tags where applicable
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 documentation
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds and edge cases, and registration order or lifecycle sequencing
Avoid obvious comments such as// increment i
Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and 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, if any
Comments MUST NOT be trivial, redundant, or misleading. Prefer explainingwhyandwhen, not justwhat
Code should remain understandable without requiring external context. Prefer slightly more explanation over too little for framework code
Missing required documentation is a coding standards violation. Code that does not meet the documentation rules is considered incomplete
Do not rely on implicit imports. Declare every requiredusingexplicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace patternGFramework.{Module}.{Feature}with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, and con...
Files:
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T11:24:07.973Z
Learning: All coding rules are defined in AGENTS.md - Follow them strictly
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T11:24:07.973Z
Learning: IArchitecture should act as the top-level container responsible for lifecycle management, component registration, module installation, and unified service access
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T11:24:07.973Z
Learning: IModel layer should be responsible for long-term state and business data modeling
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T11:24:07.973Z
Learning: ISystem layer should be responsible for command execution, process orchestration, and business rule implementation
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T11:24:07.973Z
Learning: IUtility layer should provide stateless utility functions for reuse across other layers
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T11:24:07.973Z
Learning: Architecture lifecycle management should be implemented through ArchitectureLifecycle component managing Init, Ready, and Destroy phases with fine-grained initialization and destruction stages
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T11:24:07.973Z
Learning: Component coordination should use separate specialized components: ArchitectureLifecycle, ArchitectureComponentRegistry, and ArchitectureModules to maintain low responsibility density
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T11:24:07.973Z
Learning: Context propagation should use IArchitectureContext and Provider types to allow components to access architecture services through unified entry points without direct implementation coupling
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T11:24:07.973Z
Learning: EventBus implementation should provide type-safe event publishing, subscription with priority support, filters, and weak reference subscription capabilities
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T11:24:07.973Z
Learning: BindableProperty should implement reactive property model with value-change notifications to drive UI or business layer updates
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T11:24:07.973Z
Learning: Coroutine system should be frame-driven based on IYieldInstruction abstraction and scheduler, supporting common patterns like waiting for time, events, and task completion
Learnt from: CR
URL:
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-17T11:24:07.973Z
Learning: Module structure should be organized as: abstractions layer (interfaces/contracts), implementation layer (platform-agnostic), integration layer (engine-specific), and generator layer (code generation)
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
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.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Public API changes must be covered by unit or integration tests
Applied to files:
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
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-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 (1)
GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs (1)
328-329: 文档更新清晰且无行为风险。该处仅为注释层面的微调,语义明确,和方法职责保持一致。
Summary by CodeRabbit
发布说明
新功能
文档
改进
测试