Skip to content

Replace Mediator pattern with CQRS pipeline behavior registration#221

Merged
GeWuYou merged 7 commits into
refactor/cqrs-architecture-decouplingfrom
refactor/cqrs-architecture-decoupling-todo-2
Apr 15, 2026
Merged

Replace Mediator pattern with CQRS pipeline behavior registration#221
GeWuYou merged 7 commits into
refactor/cqrs-architecture-decouplingfrom
refactor/cqrs-architecture-decoupling-todo-2

Conversation

@GeWuYou

@GeWuYou GeWuYou commented Apr 14, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

更新说明

  • 新增功能

    • 为上下文感知对象新增完整 CQRS 扩展(命令/查询/通知/流),并新增协程版命令发送,支持错误回调与取消传播。
    • 新增上下文级同步/异步命令与查询便捷入口,简化调用体验。
  • 兼容性

    • 引入 RegisterCqrsPipelineBehavior 新 API,保留旧名称作为过时别名以兼容现有调用。
    • 旧的 Mediator 风格扩展标记为过时并委托到 CQRS 扩展。
  • 文档

    • 文档改为“内建 CQRS 运行时”描述,示例与用法已同步更新。

GeWuYou added 2 commits April 14, 2026 22:30
- 新增 CQRS 详细文档,介绍命令查询职责分离模式
- 添加核心框架概述文档,包含架构图和快速开始指南
- 详细介绍五层架构设计和组件联动机制
- 提供完整的最佳实践和设计理念说明
- 添加架构生命周期管理和模块化设计说明
- 新增 CQRS 模块详细文档,介绍命令查询职责分离模式
- 添加核心框架架构概述和五层架构设计说明
- 补充快速开始指南和最佳实践建议
- 完善包说明和组件联动机制介绍
- 添加架构生命周期管理和模块化设计说明
@coderabbitai

coderabbitai Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

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

Use the following commands to manage reviews:

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

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9a2bcbb6-ebfa-4115-bf76-92125c7766a2

📥 Commits

Reviewing files that changed from the base of the PR and between 4c0a99d and c0e2e9a.

📒 Files selected for processing (1)
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (3)
**/*.cs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> where applicable
Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, and edge cases
Core framework components (Architecture, Module, System, Context, Registry, Service Module, Lifecycle types) MUST include high-level explanations of responsibilities, lifecycle, interactions, and design rationale
Generated logic and source generator pipelines MUST explain what is generated, why it is generated, semantic assumptions, and diagnostic or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling
Do not rely on implicit imports; declare every required using explicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, constants use PascalCase; interfaces use I prefix; parameters and locals use camelCase; private fields use _camelCase
Use 4 spaces for indentation (not tabs), use Allman braces, and keep using directives at the top of the file sorted consistently
Prefer one primary type per file unless the surrounding project already uses a different local pattern
Keep a single source file under roughly 800-1000 lines; if a file grows beyond that range, check whether responsibilities should be split before continuing
Keep line length readable, with around 120 characters as the preferred upper bound
Prefer explicit, readable code over clever shorthand in framework internals
Match existing async patterns and naming conventions (Async suffix for asynchronous methods) in C#
Avoid hidden side effects in property getters, constructors, and ...

Files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
**/*.{cs,csproj}

📄 CodeRabbit inference engine (AGENTS.md)

Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical

Files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
GFramework.{Core,Game,Ecs.Arch}/**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

Core / Game / Ecs.Arch implementation projects must target net8.0;net9.0;net10.0 and provide platform-independent implementations

Files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-05T15:30:46.211Z
Learning: Implement CQRS pattern (Command Query Responsibility Segregation) with support for both synchronous and asynchronous execution, using Mediator pattern integrated via source code generators
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T01:05:57.641Z
Learning: All coding rules and AI agent instructions are defined in AGENTS.md - follow them strictly
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T01:05:57.641Z
Learning: Implement CQRS pattern with command and query separation, supporting both synchronous and asynchronous execution with built-in runtime, behavior pipelines, and automatic handler registration
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T01:05:57.641Z
Learning: Implement EventBus as a type-safe event system supporting publication, subscription, priority, filters, and weak-reference subscriptions for loose-coupling module communication
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T01:05:57.641Z
Learning: Use BindableProperty for implementing reactive property models with value change notifications to drive UI or business layer updates for lightweight state synchronization
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T01:05:57.641Z
Learning: Implement coroutine system using `IYieldInstruction` abstraction and scheduler patterns to support frame-driven execution with common patterns like wait time, events, and task completion
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T01:05:57.641Z
Learning: Use IoC with `MicrosoftDiContainer` wrapping `Microsoft.Extensions.DependencyInjection` for unified component registration and service resolution
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T01:05:57.641Z
Learning: Register framework built-in services through `IServiceModule` pattern (e.g., EventBus, CommandExecutor, QueryExecutor) for infrastructure capability assembly
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T01:05:57.641Z
Learning: Organize module structure as abstraction layer + implementation layer + integration layer + generator layer with stable abstractions, replaceable implementations, isolated engine integration, and independently evolving generators
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
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

Applied to files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to **/*.cs : Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, and edge cases

Applied to files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
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.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to docs/zh-CN/**/*.md : When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in `docs/zh-CN/` in the same change

Applied to files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.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.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
🔇 Additional comments (2)
GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs (2)

15-35: 公开 API 的 XML 契约已完整覆盖并与实现一致。

<param>/<returns>/<exception>/<remarks> 信息齐全,且取消与故障语义说明清晰,便于调用方正确处理协程完成状态。

As per coding guidelines **/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> where applicable.


49-71: 取消与故障分支处理顺序正确,异常栈保留实现合理。

先处理 IsCanceled 再处理 IsFaulted,并使用 ExceptionDispatchInfo 重抛,避免状态混淆与调试栈信息丢失。


📝 Walkthrough

Walkthrough

将对外 Mediator 调用与命名迁移为内建 CQRS 运行时:新增并推广 RegisterCqrsPipelineBehavior(保留带 [Obsolete]RegisterMediatorBehavior 兼容 shim);添加 IContextAware 的 CQRS 同步/异步扩展与协程支持;更新测试、依赖与文档示例。

Changes

Cohort / File(s) Summary
抽象与 IoC 接口
GFramework.Core.Abstractions/Architectures/IArchitecture.cs, GFramework.Core.Abstractions/Ioc/IIocContainer.cs
新增 RegisterCqrsPipelineBehavior<TBehavior>();将 RegisterMediatorBehavior<TBehavior>() 标注为 [Obsolete] 并作兼容委托保留。
项目/包引用
GFramework.Core.Abstractions/GFramework.Core.Abstractions.csproj, GFramework.Core.Tests/GFramework.Core.Tests.csproj
移除 Mediator.AbstractionsMediator.SourceGenerator 测试引用,改用/添加 Microsoft.Extensions.DependencyInjection.Abstractions 并调整测试项目包引用。
核心注册与模块
GFramework.Core/Architectures/Architecture.cs, GFramework.Core/Architectures/ArchitectureModules.cs, GFramework.Core/Ioc/MicrosoftDiContainer.cs
新增 RegisterCqrsPipelineBehavior<TBehavior>() 并将原 RegisterMediatorBehavior 改为带 [Obsolete] 的转发实现,调整日志与文档注释。
IContextAware CQRS 扩展
GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs, GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs, GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs
新增一套同步/异步请求、命令、查询、发布与流式扩展,使用 ArgumentNullException.ThrowIfNull 校验并直接委托到架构上下文的方法。
Mediator 兼容扩展
GFramework.Core/Extensions/ContextAwareMediatorCommandExtensions.cs, .../ContextAwareMediatorExtensions.cs, .../ContextAwareMediatorQueryExtensions.cs
将原 Mediator 扩展标注为 [Obsolete],实现改为委托到新的 CQRS 扩展以维持旧调用位点(移除重复空检查)。
协程扩展与迁移
GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs, GFramework.Core/Coroutine/Extensions/MediatorCoroutineExtensions.cs
新增 CqrsCoroutineExtensions.SendCommandCoroutineMediatorCoroutineExtensions 标注为弃用并改为委托到 CQRS 实现;新增/迁移相关协程测试(新增 CQRS 协程测试,删除旧 Mediator 协程测试)。
测试修改
GFramework.Core.Tests/Architectures/*.cs, GFramework.Core.Tests/Coroutine/*, GFramework.Core.Tests/GlobalUsings.cs
测试中改用未限定的 GFramework.Core.Abstractions.Cqrs 类型名,新增 RegisterCqrsPipelineBehavior 测试与协程错误/取消行为测试,删除旧 Mediator 测试文件,调整全局 using 与测试项目依赖。
Godot 集成
GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs
将内部调用从 Mediator 扩展切换为新的 CQRS 扩展(行为与外部 API 不变)。
文档与示例
docs/zh-CN/core/cqrs.md, docs/zh-CN/core/index.md, CLAUDE.md, GFramework.Core/Cqrs/Internal/CqrsHandlerRegistrar.cs, GFramework.Core/Architectures/ArchitectureBootstrapper.cs
文档示例与说明由 “Mediator” 切换为“内建 CQRS runtime”;示例代码、生命周期回调名与行为约束调整;若干 XML 注释/字符串更新。

Sequence Diagram(s)

sequenceDiagram
    participant CA as IContextAware
    participant CTX as ArchitectureContext
    participant CQRS as CQRS Runtime
    participant PB as PipelineBehaviors
    participant H as Handler

    CA->>CTX: GetContext()
    CA->>CTX: SendAsync(command/request/notification)
    CTX->>CQRS: Dispatch(command/request/notification)
    CQRS->>PB: Execute registered pipeline behaviors
    PB->>CQRS: next()/continue
    CQRS->>H: Invoke handler
    H-->>CQRS: Return result
    CQRS-->>CTX: Return ValueTask/Task
    CTX-->>CA: Return result / coroutine awaitable
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 74.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确反映了主要变更:将 Mediator 模式替换为 CQRS 管道行为注册,这是整个 PR 的核心目标。

✏️ 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 refactor/cqrs-architecture-decoupling-todo-2

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

@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: 4

Caution

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

⚠️ Outside diff range comments (2)
docs/zh-CN/core/cqrs.md (1)

333-343: ⚠️ Potential issue | 🟡 Minor

管道行为示例的 Handle 签名顺序写反了。

这里把 CancellationToken 放在了 next 前面,但仓库里实际的 IPipelineBehavior 实现签名是 (message, next, cancellationToken)。现在这几段示例直接复制会编译失败。

As per coding guidelines "Keep code samples, package names, and command examples in documentation aligned with the current repository state".

Also applies to: 356-363, 388-395

🤖 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 333 - 343, The Handle method signature
in the LoggingBehavior<TMessage, TResponse> example is ordered incorrectly: the
repository's IPipelineBehavior expects Handle(TMessage message,
MessageHandlerDelegate<TMessage, TResponse> next, CancellationToken
cancellationToken). Update the example to match that signature (move
MessageHandlerDelegate<TMessage, TResponse> next before CancellationToken
cancellationToken) and apply the same fix to the other pipeline examples
mentioned (the other LoggingBehavior/Handle examples using IPipelineBehavior and
MessageHandlerDelegate).
GFramework.Core.Tests/Architectures/GameContextTests.cs (1)

397-453: ⚠️ Potential issue | 🟠 Major

为已修改的公共成员补充 XML 文档注释

TestArchitectureContext 在该区间内修改了多个 public 方法签名(如 SendRequestAsyncSendCommandAsyncSendQueryAsyncPublishAsyncCreateStreamSendAsync 等),但仍缺少对应的 /// 文档(至少 summary/param/returns,必要时 exception/remarks)。按仓库规则这类变更需要补齐文档。

建议补充方式(示例)
+    /// <summary>
+    ///     异步发送 CQRS 请求并返回响应。
+    /// </summary>
+    /// <typeparam name="TResponse">响应类型</typeparam>
+    /// <param name="request">请求对象</param>
+    /// <param name="cancellationToken">取消令牌</param>
+    /// <returns>请求响应</returns>
+    /// <exception cref="NotImplementedException">测试桩未实现实际逻辑时抛出</exception>
     public ValueTask<TResponse> SendRequestAsync<TResponse>(IRequest<TResponse> request,
         CancellationToken cancellationToken = default)

As per coding guidelines, **/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> where applicable.

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

In `@GFramework.Core.Tests/Architectures/GameContextTests.cs` around lines 397 -
453, Multiple public methods in TestArchitectureContext (SendRequestAsync,
SendRequest, SendCommandAsync, SendCommand, SendQueryAsync, SendQuery,
PublishAsync, CreateStream, SendAsync<TCommand>, SendAsync<TResponse>) lack
required XML documentation; add triple-slash XML comments for each public member
including at minimum <summary>, <param> (for request/command/query/notification
and cancellationToken where present) and <returns> (or <remarks>/<exception> if
applicable) describing behavior and return values, and include any exceptions
thrown; ensure the comments are placed immediately above the method declarations
and use the exact method/type names shown to locate them.
🧹 Nitpick comments (5)
GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs (2)

11-24: 建议在 XML 文档中添加 <exception> 标签。

根据编码规范,XML 文档应包含 <exception> 标签说明可能抛出的异常。此方法使用 ArgumentNullException.ThrowIfNull,应在文档中声明。

📝 建议的文档补充
     /// <summary>
     ///     发送查询的同步版本(不推荐,仅用于兼容同步调用链)。
     /// </summary>
     /// <typeparam name="TResponse">查询响应类型。</typeparam>
     /// <param name="contextAware">实现 <see cref="IContextAware" /> 接口的对象。</param>
     /// <param name="query">要发送的查询对象。</param>
     /// <returns>查询结果。</returns>
+    /// <exception cref="ArgumentNullException">当 <paramref name="contextAware"/> 或 <paramref name="query"/> 为 null 时抛出。</exception>
     public static TResponse SendQuery<TResponse>(this IContextAware contextAware, IQuery<TResponse> query)

As per coding guidelines: "All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> where applicable"

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

In `@GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs` around lines
11 - 24, Update the XML documentation for the extension method
SendQuery<TResponse>(this IContextAware contextAware, IQuery<TResponse> query)
to include <exception> tags describing the ArgumentNullException thrown by
ArgumentNullException.ThrowIfNull for both contextAware and query (and any other
exceptions propagated from contextAware.GetContext().SendQuery if applicable);
ensure the <param> and <returns> remain and add clear wording for each exception
entry to match the project's XML-doc conventions.

26-43: 同样建议为异步方法添加 <exception> 文档。

📝 建议的文档补充
     /// <summary>
     ///     异步发送查询并返回结果。
     /// </summary>
     /// <typeparam name="TResponse">查询响应类型。</typeparam>
     /// <param name="contextAware">实现 <see cref="IContextAware" /> 接口的对象。</param>
     /// <param name="query">要发送的查询对象。</param>
     /// <param name="cancellationToken">取消令牌,用于取消操作。</param>
     /// <returns>包含查询结果的 <see cref="ValueTask{TResult}" />。</returns>
+    /// <exception cref="ArgumentNullException">当 <paramref name="contextAware"/> 或 <paramref name="query"/> 为 null 时抛出。</exception>
     public static ValueTask<TResponse> SendQueryAsync<TResponse>(
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs` around lines
26 - 43, The SendQueryAsync extension method lacks XML <exception>
documentation; update the method's docblock for SendQueryAsync to include
<exception cref="System.ArgumentNullException"> entries describing when
contextAware or query is null, and add an <exception
cref="System.OperationCanceledException"> noting that the operation may be
cancelled via the cancellationToken; also optionally mention any exceptions
propagated from the underlying call to
contextAware.GetContext().SendQueryAsync(...) so callers know what can be
thrown.
GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs (2)

11-24: 建议添加 <exception> 文档标签。

与查询扩展方法相同,建议为 ArgumentNullException 添加文档说明。

📝 建议的文档补充
     /// <summary>
     ///     发送命令的同步版本(不推荐,仅用于兼容同步调用链)。
     /// </summary>
     /// <typeparam name="TResponse">命令响应类型。</typeparam>
     /// <param name="contextAware">实现 <see cref="IContextAware" /> 接口的对象。</param>
     /// <param name="command">要发送的命令对象。</param>
     /// <returns>命令执行结果。</returns>
+    /// <exception cref="ArgumentNullException">当 <paramref name="contextAware"/> 或 <paramref name="command"/> 为 null 时抛出。</exception>
     public static TResponse SendCommand<TResponse>(this IContextAware contextAware, ICommand<TResponse> command)

As per coding guidelines: "All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> where applicable"

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

In `@GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs` around lines
11 - 24, Add XML <exception> documentation to the SendCommand<TResponse>
extension: document that ArgumentNullException is thrown for null contextAware
and for null command (reference the IContextAware parameter and the
ICommand<TResponse> parameter), matching the query extension style; ensure the
method summary's XML comments include two <exception
cref="System.ArgumentNullException"> entries describing which parameter causes
the throw (contextAware via ArgumentNullException.ThrowIfNull and command via
ArgumentNullException.ThrowIfNull) and keep wording consistent with other
extension methods.

26-43: 同样建议为异步方法添加 <exception> 文档。

📝 建议的文档补充
     /// <summary>
     ///     异步发送命令并返回结果。
     /// </summary>
     /// <typeparam name="TResponse">命令响应类型。</typeparam>
     /// <param name="contextAware">实现 <see cref="IContextAware" /> 接口的对象。</param>
     /// <param name="command">要发送的命令对象。</param>
     /// <param name="cancellationToken">取消令牌,用于取消操作。</param>
     /// <returns>包含命令执行结果的 <see cref="ValueTask{TResult}" />。</returns>
+    /// <exception cref="ArgumentNullException">当 <paramref name="contextAware"/> 或 <paramref name="command"/> 为 null 时抛出。</exception>
     public static ValueTask<TResponse> SendCommandAsync<TResponse>(
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs` around lines
26 - 43, 为异步扩展方法 SendCommandAsync<TResponse> 补充 XML 文档中的 <exception> 标签:声明当
contextAware 或 command 为 null 时会抛出的 ArgumentNullException(对应参数名 contextAware 和
command),并注明在传入的 cancellationToken 被触发时可能抛出的 OperationCanceledException(或
TaskCanceledException 视实现而定);在更新 IContextAware.GetContext().SendCommandAsync
调用处如有其他已知异常,也一并在文档中列出并描述。
GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs (1)

38-41: 建议统一 onError 与抛出分支的异常语义。

Line 39 当前把 AggregateException 传给回调,而 Line 41 会优先抛内部异常;同一失败场景在两条路径上异常类型不一致,调用方处理会分叉。

建议修改
-        if (onError != null)
-            onError.Invoke(task.Exception!);
-        else
-            throw task.Exception!.InnerException ?? task.Exception;
+        var exception = task.Exception!.InnerException ?? task.Exception;
+        if (onError != null)
+            onError.Invoke(exception);
+        else
+            throw exception;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs` around lines
38 - 41, Unify the exception semantics by unwrapping AggregateException before
both the callback and the throw: compute a single Exception ex =
task.Exception.InnerException ?? task.Exception and then use onError.Invoke(ex)
when onError != null, otherwise throw ex; reference task.Exception and onError
in your change so both branches receive the same (unwrapped) exception instance.
🤖 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`:
- Around line 207-219: The docs claim "handlers are automatically registered"
but the startup only scans architectureType.Assembly and
typeof(ArchitectureContext).Assembly, so update the documentation near
RegisterCqrsPipelineBehavior<,> to accurately state the default scanning scope
("defaults to the current architecture assembly and the Core/ArchitectureContext
assembly") and add guidance for including handlers from other modules by
describing the extension point or API to register additional assemblies (e.g.,
explain how to pass extra assemblies into the CQRS handler scanner or where to
hook in assembly registration), referencing RegisterCqrsPipelineBehavior,
architectureType.Assembly, and ArchitectureContext so readers can locate the
relevant bootstrap behavior.

In `@GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs`:
- Around line 62-65: The test suite removed coverage for the old public shim
RegisterMediatorBehavior after renaming to RegisterCqrsPipelineBehavior; add a
small smoke test in ArchitectureModulesBehaviorTests that calls the legacy API
(e.g.
target.RegisterMediatorBehavior<TrackingPipelineBehavior<ModuleBehaviorRequest,
string>>()) and asserts the same behavior as RegisterCqrsPipelineBehavior (e.g.
pipeline is registered/applied in the ModuleTestArchitecture), so the
compatibility shim remains guarded by tests; place the new test alongside
RegisterCqrsPipelineBehavior_Should_Apply_Pipeline_Behavior_To_Request and use
the same setup/assertion patterns to keep parity.

In `@GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs`:
- Around line 22-26: The public method SendCommandCoroutine<TCommand>(this
IContextAware contextAware, TCommand command, Action<Exception>? onError = null)
is missing XML <exception> documentation for the ArgumentNullException it can
throw; update the XML doc comment for SendCommandCoroutine to include one or
more <exception cref="System.ArgumentNullException"> entries that explicitly
state which parameters (e.g., contextAware and command) cause the exception when
null and the circumstances, and ensure the summary/param/returns blocks remain
present and consistent with the existing doc style for other public members.

In `@GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs`:
- Around line 20-29: Add XML <exception> documentation to each public extension
method in ContextAwareCqrsExtensions (e.g., SendRequestAsync<TResponse>,
SendRequestAsync, PublishEventAsync<TEvent>, PublishEventAsync, and other public
overloads) stating that an ArgumentNullException is thrown when required
parameters are null; for each method include an <exception
cref="System.ArgumentNullException"> element that names the null parameter(s)
(for example: "Thrown if contextAware or request is null" for
SendRequestAsync<TResponse>) and keep the wording consistent with other XML
comments in the project.

---

Outside diff comments:
In `@docs/zh-CN/core/cqrs.md`:
- Around line 333-343: The Handle method signature in the
LoggingBehavior<TMessage, TResponse> example is ordered incorrectly: the
repository's IPipelineBehavior expects Handle(TMessage message,
MessageHandlerDelegate<TMessage, TResponse> next, CancellationToken
cancellationToken). Update the example to match that signature (move
MessageHandlerDelegate<TMessage, TResponse> next before CancellationToken
cancellationToken) and apply the same fix to the other pipeline examples
mentioned (the other LoggingBehavior/Handle examples using IPipelineBehavior and
MessageHandlerDelegate).

In `@GFramework.Core.Tests/Architectures/GameContextTests.cs`:
- Around line 397-453: Multiple public methods in TestArchitectureContext
(SendRequestAsync, SendRequest, SendCommandAsync, SendCommand, SendQueryAsync,
SendQuery, PublishAsync, CreateStream, SendAsync<TCommand>,
SendAsync<TResponse>) lack required XML documentation; add triple-slash XML
comments for each public member including at minimum <summary>, <param> (for
request/command/query/notification and cancellationToken where present) and
<returns> (or <remarks>/<exception> if applicable) describing behavior and
return values, and include any exceptions thrown; ensure the comments are placed
immediately above the method declarations and use the exact method/type names
shown to locate them.

---

Nitpick comments:
In `@GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs`:
- Around line 38-41: Unify the exception semantics by unwrapping
AggregateException before both the callback and the throw: compute a single
Exception ex = task.Exception.InnerException ?? task.Exception and then use
onError.Invoke(ex) when onError != null, otherwise throw ex; reference
task.Exception and onError in your change so both branches receive the same
(unwrapped) exception instance.

In `@GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs`:
- Around line 11-24: Add XML <exception> documentation to the
SendCommand<TResponse> extension: document that ArgumentNullException is thrown
for null contextAware and for null command (reference the IContextAware
parameter and the ICommand<TResponse> parameter), matching the query extension
style; ensure the method summary's XML comments include two <exception
cref="System.ArgumentNullException"> entries describing which parameter causes
the throw (contextAware via ArgumentNullException.ThrowIfNull and command via
ArgumentNullException.ThrowIfNull) and keep wording consistent with other
extension methods.
- Around line 26-43: 为异步扩展方法 SendCommandAsync<TResponse> 补充 XML 文档中的 <exception>
标签:声明当 contextAware 或 command 为 null 时会抛出的 ArgumentNullException(对应参数名
contextAware 和 command),并注明在传入的 cancellationToken 被触发时可能抛出的
OperationCanceledException(或 TaskCanceledException 视实现而定);在更新
IContextAware.GetContext().SendCommandAsync 调用处如有其他已知异常,也一并在文档中列出并描述。

In `@GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs`:
- Around line 11-24: Update the XML documentation for the extension method
SendQuery<TResponse>(this IContextAware contextAware, IQuery<TResponse> query)
to include <exception> tags describing the ArgumentNullException thrown by
ArgumentNullException.ThrowIfNull for both contextAware and query (and any other
exceptions propagated from contextAware.GetContext().SendQuery if applicable);
ensure the <param> and <returns> remain and add clear wording for each exception
entry to match the project's XML-doc conventions.
- Around line 26-43: The SendQueryAsync extension method lacks XML <exception>
documentation; update the method's docblock for SendQueryAsync to include
<exception cref="System.ArgumentNullException"> entries describing when
contextAware or query is null, and add an <exception
cref="System.OperationCanceledException"> noting that the operation may be
cancelled via the cancellationToken; also optionally mention any exceptions
propagated from the underlying call to
contextAware.GetContext().SendQueryAsync(...) so callers know what can be
thrown.
🪄 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: 6e6cd578-a838-47fb-97ef-1e657e5088d5

📥 Commits

Reviewing files that changed from the base of the PR and between 156fd4d and 115fe65.

📒 Files selected for processing (27)
  • CLAUDE.md
  • GFramework.Core.Abstractions/Architectures/IArchitecture.cs
  • GFramework.Core.Abstractions/GFramework.Core.Abstractions.csproj
  • GFramework.Core.Abstractions/Ioc/IIocContainer.cs
  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core.Tests/Coroutine/MediatorCoroutineExtensionsTests.cs
  • GFramework.Core.Tests/GFramework.Core.Tests.csproj
  • GFramework.Core/Architectures/Architecture.cs
  • GFramework.Core/Architectures/ArchitectureBootstrapper.cs
  • GFramework.Core/Architectures/ArchitectureModules.cs
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
  • GFramework.Core/Coroutine/Extensions/MediatorCoroutineExtensions.cs
  • GFramework.Core/Cqrs/Internal/CqrsHandlerRegistrar.cs
  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs
  • GFramework.Core/Extensions/ContextAwareMediatorCommandExtensions.cs
  • GFramework.Core/Extensions/ContextAwareMediatorExtensions.cs
  • GFramework.Core/Extensions/ContextAwareMediatorQueryExtensions.cs
  • GFramework.Core/Ioc/MicrosoftDiContainer.cs
  • GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs
  • docs/zh-CN/core/cqrs.md
  • docs/zh-CN/core/index.md
💤 Files with no reviewable changes (2)
  • GFramework.Core.Tests/GFramework.Core.Tests.csproj
  • GFramework.Core.Tests/Coroutine/MediatorCoroutineExtensionsTests.cs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (14)
**/*.csproj

📄 CodeRabbit inference engine (AGENTS.md)

Follow repository defaults: ImplicitUsings disabled, Nullable enabled, GenerateDocumentationFile enabled for shipped libraries, LangVersion generally preview

Files:

  • GFramework.Core.Abstractions/GFramework.Core.Abstractions.csproj
**/*.{cs,csproj}

📄 CodeRabbit inference engine (AGENTS.md)

Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical

Files:

  • GFramework.Core.Abstractions/GFramework.Core.Abstractions.csproj
  • GFramework.Core/Architectures/ArchitectureBootstrapper.cs
  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core/Extensions/ContextAwareMediatorExtensions.cs
  • GFramework.Core.Abstractions/Ioc/IIocContainer.cs
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
  • GFramework.Core.Abstractions/Architectures/IArchitecture.cs
  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core/Architectures/ArchitectureModules.cs
  • GFramework.Core/Extensions/ContextAwareMediatorCommandExtensions.cs
  • GFramework.Core/Architectures/Architecture.cs
  • GFramework.Core/Coroutine/Extensions/MediatorCoroutineExtensions.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core/Ioc/MicrosoftDiContainer.cs
  • GFramework.Core/Extensions/ContextAwareMediatorQueryExtensions.cs
  • GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
  • GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs
  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
  • GFramework.Core/Cqrs/Internal/CqrsHandlerRegistrar.cs
!{**/Abstractions/**,**/SourceGenerators/**}/**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

Core, Game, and Ecs.Arch implementations should be platform-agnostic and target net8.0, net9.0, and net10.0

Files:

  • GFramework.Core.Abstractions/GFramework.Core.Abstractions.csproj
  • CLAUDE.md
  • GFramework.Core/Architectures/ArchitectureBootstrapper.cs
  • docs/zh-CN/core/index.md
  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core/Extensions/ContextAwareMediatorExtensions.cs
  • GFramework.Core.Abstractions/Ioc/IIocContainer.cs
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
  • GFramework.Core.Abstractions/Architectures/IArchitecture.cs
  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core/Architectures/ArchitectureModules.cs
  • GFramework.Core/Extensions/ContextAwareMediatorCommandExtensions.cs
  • docs/zh-CN/core/cqrs.md
  • GFramework.Core/Architectures/Architecture.cs
  • GFramework.Core/Coroutine/Extensions/MediatorCoroutineExtensions.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core/Ioc/MicrosoftDiContainer.cs
  • GFramework.Core/Extensions/ContextAwareMediatorQueryExtensions.cs
  • GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
  • GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs
  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
  • GFramework.Core/Cqrs/Internal/CqrsHandlerRegistrar.cs
**/*.cs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> where applicable
Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, and edge cases
Core framework components (Architecture, Module, System, Context, Registry, Service Module, Lifecycle types) MUST include high-level explanations of responsibilities, lifecycle, interactions, and design rationale
Generated logic and source generator pipelines MUST explain what is generated, why it is generated, semantic assumptions, and diagnostic or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling
Do not rely on implicit imports; declare every required using explicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, constants use PascalCase; interfaces use I prefix; parameters and locals use camelCase; private fields use _camelCase
Use 4 spaces for indentation (not tabs), use Allman braces, and keep using directives at the top of the file sorted consistently
Prefer one primary type per file unless the surrounding project already uses a different local pattern
Keep a single source file under roughly 800-1000 lines; if a file grows beyond that range, check whether responsibilities should be split before continuing
Keep line length readable, with around 120 characters as the preferred upper bound
Prefer explicit, readable code over clever shorthand in framework internals
Match existing async patterns and naming conventions (Async suffix for asynchronous methods) in C#
Avoid hidden side effects in property getters, constructors, and ...

Files:

  • GFramework.Core/Architectures/ArchitectureBootstrapper.cs
  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core/Extensions/ContextAwareMediatorExtensions.cs
  • GFramework.Core.Abstractions/Ioc/IIocContainer.cs
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
  • GFramework.Core.Abstractions/Architectures/IArchitecture.cs
  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core/Architectures/ArchitectureModules.cs
  • GFramework.Core/Extensions/ContextAwareMediatorCommandExtensions.cs
  • GFramework.Core/Architectures/Architecture.cs
  • GFramework.Core/Coroutine/Extensions/MediatorCoroutineExtensions.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core/Ioc/MicrosoftDiContainer.cs
  • GFramework.Core/Extensions/ContextAwareMediatorQueryExtensions.cs
  • GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
  • GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs
  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
  • GFramework.Core/Cqrs/Internal/CqrsHandlerRegistrar.cs
**/*[Log]*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

[Log] source generator attribute should automatically generate log fields and logging helper methods

Files:

  • GFramework.Core/Architectures/ArchitectureBootstrapper.cs
  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core/Extensions/ContextAwareMediatorExtensions.cs
  • GFramework.Core.Abstractions/Ioc/IIocContainer.cs
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core/Architectures/ArchitectureModules.cs
  • GFramework.Core/Extensions/ContextAwareMediatorCommandExtensions.cs
  • GFramework.Core/Coroutine/Extensions/MediatorCoroutineExtensions.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core/Ioc/MicrosoftDiContainer.cs
  • GFramework.Core/Extensions/ContextAwareMediatorQueryExtensions.cs
  • GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
  • GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
  • GFramework.Core/Cqrs/Internal/CqrsHandlerRegistrar.cs
**/*[Priority]*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

[Priority] source generator attribute should automatically generate priority comparison implementations

Files:

  • GFramework.Core/Architectures/ArchitectureBootstrapper.cs
  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core/Extensions/ContextAwareMediatorExtensions.cs
  • GFramework.Core.Abstractions/Ioc/IIocContainer.cs
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
  • GFramework.Core.Abstractions/Architectures/IArchitecture.cs
  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core/Architectures/ArchitectureModules.cs
  • GFramework.Core/Extensions/ContextAwareMediatorCommandExtensions.cs
  • GFramework.Core/Architectures/Architecture.cs
  • GFramework.Core/Coroutine/Extensions/MediatorCoroutineExtensions.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core/Ioc/MicrosoftDiContainer.cs
  • GFramework.Core/Extensions/ContextAwareMediatorQueryExtensions.cs
  • GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
  • GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs
  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
  • GFramework.Core/Cqrs/Internal/CqrsHandlerRegistrar.cs
**/*[GenerateEnumExtensions]*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

[GenerateEnumExtensions] source generator attribute should automatically generate enum extension capabilities

Files:

  • GFramework.Core/Architectures/ArchitectureBootstrapper.cs
  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core/Extensions/ContextAwareMediatorExtensions.cs
  • GFramework.Core.Abstractions/Ioc/IIocContainer.cs
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
  • GFramework.Core.Abstractions/Architectures/IArchitecture.cs
  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core/Architectures/ArchitectureModules.cs
  • GFramework.Core/Extensions/ContextAwareMediatorCommandExtensions.cs
  • GFramework.Core/Architectures/Architecture.cs
  • GFramework.Core/Coroutine/Extensions/MediatorCoroutineExtensions.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core/Ioc/MicrosoftDiContainer.cs
  • GFramework.Core/Extensions/ContextAwareMediatorQueryExtensions.cs
  • GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
  • GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs
  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
  • GFramework.Core/Cqrs/Internal/CqrsHandlerRegistrar.cs
**/*[ContextAware]*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

[ContextAware] source generator attribute should automatically implement IContextAware boilerplate logic

Files:

  • GFramework.Core/Architectures/ArchitectureBootstrapper.cs
  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core/Extensions/ContextAwareMediatorExtensions.cs
  • GFramework.Core.Abstractions/Ioc/IIocContainer.cs
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
  • GFramework.Core.Abstractions/Architectures/IArchitecture.cs
  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core/Architectures/ArchitectureModules.cs
  • GFramework.Core/Extensions/ContextAwareMediatorCommandExtensions.cs
  • GFramework.Core/Architectures/Architecture.cs
  • GFramework.Core/Coroutine/Extensions/MediatorCoroutineExtensions.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core/Ioc/MicrosoftDiContainer.cs
  • GFramework.Core/Extensions/ContextAwareMediatorQueryExtensions.cs
  • GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
  • GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs
  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
  • GFramework.Core/Cqrs/Internal/CqrsHandlerRegistrar.cs
docs/**/*.md

📄 CodeRabbit inference engine (AGENTS.md)

docs/**/*.md: Update 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
For integration-oriented features such as the AI-First config system, documentation MUST cover project directory layout, file conventions, required project/package wiring, minimal working usage example, and migration/compatibility notes

Documentation should be organized with root README.md, sub-module README.md files, and detailed topic guides in docs/ directory with Chinese content in docs/zh-CN/

Files:

  • docs/zh-CN/core/index.md
  • docs/zh-CN/core/cqrs.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/core/index.md
  • docs/zh-CN/core/cqrs.md
**/*Abstractions/**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

Abstractions projects should contain only interfaces and contract definitions without runtime implementation logic

Files:

  • GFramework.Core.Abstractions/Ioc/IIocContainer.cs
  • GFramework.Core.Abstractions/Architectures/IArchitecture.cs
**/*Container*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

IoC container implementation should wrap Microsoft.Extensions.DependencyInjection for unified component registration and service resolution

Files:

  • GFramework.Core.Abstractions/Ioc/IIocContainer.cs
  • GFramework.Core/Ioc/MicrosoftDiContainer.cs
**/*Coroutine*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

Coroutine system must be frame-driven, based on IYieldInstruction abstraction, and support waiting on time, events, and task completion

Files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
  • GFramework.Core/Coroutine/Extensions/MediatorCoroutineExtensions.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs
**/Architectures/Architecture.cs

📄 CodeRabbit inference engine (CLAUDE.md)

Architecture class serves as the top-level orchestrator responsible for lifecycle management, component registration, module installation, and unified service access

Files:

  • GFramework.Core/Architectures/Architecture.cs
🧠 Learnings (20)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-05T15:30:46.211Z
Learning: Implement CQRS pattern (Command Query Responsibility Segregation) with support for both synchronous and asynchronous execution, using Mediator pattern integrated via source code generators
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-14T14:56:42.006Z
Learning: Module boundaries should be strictly maintained to ensure abstractions are stable, implementations are replaceable, engine integrations are isolated, and generators can evolve independently
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-14T14:56:42.006Z
Learning: Design should prioritize clear module boundaries, composable service registration, stable abstract contracts, and moderate use of source code generation over consolidating all capabilities into a single core class
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to **/*.cs : If a framework abstraction changes meaning or intended usage, update the explanatory comments in code as part of the same change

Applied to files:

  • GFramework.Core.Abstractions/GFramework.Core.Abstractions.csproj
📚 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:

  • GFramework.Core.Abstractions/GFramework.Core.Abstractions.csproj
📚 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: Implement CQRS pattern (Command Query Responsibility Segregation) with support for both synchronous and asynchronous execution, using Mediator pattern integrated via source code generators

Applied to files:

  • CLAUDE.md
  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core/Extensions/ContextAwareMediatorCommandExtensions.cs
  • docs/zh-CN/core/cqrs.md
  • GFramework.Core/Coroutine/Extensions/MediatorCoroutineExtensions.cs
  • GFramework.Core/Extensions/ContextAwareMediatorQueryExtensions.cs
  • GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs
  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to **/*.cs : Core framework components (Architecture, Module, System, Context, Registry, Service Module, Lifecycle types) MUST include high-level explanations of responsibilities, lifecycle, interactions, and design rationale

Applied to files:

  • GFramework.Core/Architectures/ArchitectureBootstrapper.cs
  • GFramework.Core.Abstractions/Architectures/IArchitecture.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 MicrosoftDiContainer wrapping Microsoft.Extensions.DependencyInjection for unified component registration and service resolution

Applied to files:

  • GFramework.Core/Architectures/ArchitectureBootstrapper.cs
  • GFramework.Core.Abstractions/Ioc/IIocContainer.cs
  • GFramework.Core.Abstractions/Architectures/IArchitecture.cs
  • GFramework.Core/Architectures/Architecture.cs
  • GFramework.Core/Ioc/MicrosoftDiContainer.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.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.Core/Architectures/ArchitectureBootstrapper.cs
  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core/Extensions/ContextAwareMediatorExtensions.cs
  • GFramework.Core.Abstractions/Ioc/IIocContainer.cs
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
  • GFramework.Core.Abstractions/Architectures/IArchitecture.cs
  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core/Architectures/ArchitectureModules.cs
  • GFramework.Core/Extensions/ContextAwareMediatorCommandExtensions.cs
  • GFramework.Core/Architectures/Architecture.cs
  • GFramework.Core/Coroutine/Extensions/MediatorCoroutineExtensions.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core/Ioc/MicrosoftDiContainer.cs
  • GFramework.Core/Extensions/ContextAwareMediatorQueryExtensions.cs
  • GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
  • GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs
  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
  • GFramework.Core/Cqrs/Internal/CqrsHandlerRegistrar.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to docs/zh-CN/**/*.md : When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in `docs/zh-CN/` in the same change

Applied to files:

  • docs/zh-CN/core/index.md
  • docs/zh-CN/core/cqrs.md
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to docs/**/*.md : Update relevant `README.md` or `docs/` page when behavior, setup steps, architecture guidance, or user-facing examples change

Applied to files:

  • docs/zh-CN/core/index.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: IArchitecture must serve as the top-level container responsible for lifecycle management, component registration, module installation, and unified service access

Applied to files:

  • docs/zh-CN/core/index.md
  • GFramework.Core/Architectures/ArchitectureModules.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.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 IServiceModule pattern to register built-in services (EventBus, CommandExecutor, QueryExecutor) with Architecture

Applied to files:

  • docs/zh-CN/core/index.md
  • GFramework.Core/Architectures/ArchitectureModules.cs
  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.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:

  • docs/zh-CN/core/index.md
  • GFramework.Core/Architectures/ArchitectureModules.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to **/*.Tests/*.cs : When generator behavior changes intentionally, update snapshots together with the implementation

Applied to files:

  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to **/*.Tests/*.cs : Reuse existing architecture test infrastructure when relevant: `ArchitectureTestsBase<T>`, `SyncTestArchitecture`, `AsyncTestArchitecture`

Applied to files:

  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to **/*.Tests/*.cs : Keep tests focused on observable behavior, not implementation trivia

Applied to files:

  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.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: Applies to **/*.cs : ContextAwareGenerator must automatically implement IContextAware boilerplate logic for classes decorated with [ContextAware] attribute

Applied to files:

  • GFramework.Core/Extensions/ContextAwareMediatorExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to **/*.Tests/*.cs : Source generator changes MUST be covered by generator tests; preserve snapshot-based verification patterns already used in the repository

Applied to files:

  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to **/*.cs : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs
  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to **/*.Tests/*.cs : Regression fixes should include a test that fails before the fix and passes after it

Applied to files:

  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to **/*.cs : Use the namespace pattern `GFramework.{Module}.{Feature}` with PascalCase segments

Applied to files:

  • GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
🔇 Additional comments (18)
GFramework.Core.Abstractions/Ioc/IIocContainer.cs (1)

91-106: LGTM!CQRS 管道行为注册 API 迁移实现良好。

接口变更遵循了正确的弃用模式:

  • 新增 RegisterCqrsPipelineBehavior<TBehavior>() 作为主要 API
  • 保留 RegisterMediatorBehavior<TBehavior>() 并标记 [Obsolete] 以保持向后兼容
  • XML 文档清晰说明了新旧方法的行为一致性
GFramework.Core.Abstractions/Architectures/IArchitecture.cs (1)

74-92: LGTM!架构接口的 CQRS 管道行为注册方法定义正确。

IIocContainer 接口保持一致的 API 设计,XML 文档清晰说明了对开放泛型和封闭行为类型的支持。

GFramework.Core/Architectures/Architecture.cs (1)

147-166: LGTM!实现正确遵循协调器模式。

RegisterCqrsPipelineBehavior 正确委托给 _modules,而废弃的 RegisterMediatorBehavior 通过调用新方法保持向后兼容。这与类文档中描述的"将职责委托给专门的管理器"设计一致。

GFramework.Core/Ioc/MicrosoftDiContainer.cs (2)

311-358: LGTM!CQRS 管道行为注册实现完善。

实现正确处理了两种场景:

  1. 开放泛型类型(IsGenericTypeDefinition):注册到 typeof(IPipelineBehavior<,>)
  2. 封闭类型:查找所有实现的 IPipelineBehavior<,> 接口并逐一注册

类型验证和错误处理也很到位,未实现接口时会抛出带有日志的 InvalidOperationException


360-369: LGTM!废弃方法正确委托到新实现。

GFramework.Core/Extensions/ContextAwareMediatorQueryExtensions.cs (1)

7-25: LGTM!废弃类正确委托到新的 CQRS 扩展。

类级别的 [Obsolete] 属性提供了清晰的迁移指引。移除本地空值检查是正确的,因为 ContextAwareCqrsQueryExtensions 已经处理了验证逻辑。

GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs (3)

33-46: LGTM!测试正确验证了协程返回类型。

测试设置清晰,通过 Mock 控制 SendAsync 的返回值,验证 SendCommandCoroutine 返回 IEnumerator<IYieldInstruction> 类型。


51-67: LGTM!异常传播测试覆盖了关键行为。

测试验证了当底层命令调度失败时,协程会正确重新抛出原始异常实例(使用 Is.SameAs 确保是同一实例)。这对确保异常处理的正确性非常重要。


69-89: 测试辅助类型设计合理。

TestCommand 使用 record 简洁定义,TestContextAware 通过暴露 MockContext 属性方便测试设置。符合测试辅助类型的最佳实践。

GFramework.Core/Architectures/ArchitectureModules.cs (1)

20-35: 迁移兼容层实现清晰,方向正确。

新 API 与旧 API 的转发关系明确,弃用路径可控且不会破坏现有调用点。

GFramework.Core/Coroutine/Extensions/MediatorCoroutineExtensions.cs (1)

25-43: 兼容封装做得很好。

废弃标记 + 单点转发避免了重复逻辑,符合从 Mediator 向 CQRS 迁移的预期。

GFramework.Core/Extensions/ContextAwareMediatorCommandExtensions.cs (1)

11-12: 兼容层转发实现合理。

旧命名 API 保留但逻辑集中到 CQRS 扩展,后续维护成本更低。

Also applies to: 25-26, 40-44

GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs (1)

29-34: 调用链迁移到 CQRS 扩展后仍保持原有协程执行语义,改动稳健。

Also applies to: 53-58, 77-82, 100-104

GFramework.Core.Tests/Architectures/RegistryInitializationHookBaseTests.cs (1)

183-192: 测试替身已同步新 API 命名,并保留旧方法兼容入口,更新到位。

Also applies to: 314-323

GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs (1)

20-123: 统一通过 IContextAware.GetContext() 转发到 CQRS runtime 的实现方式很干净。

GFramework.Core.Tests/Architectures/ArchitectureServicesTests.cs (1)

351-357: 测试上下文签名与新版 CQRS 抽象保持一致,这次适配是正确的。

Also applies to: 362-379, 385-385, 391-391, 398-404

GFramework.Core.Tests/Architectures/GameContextTests.cs (2)

3-3: CQRS 命名空间引入清晰且与本次迁移目标一致

这里将 CQRS 抽象显式引入,和本 PR 从 Mediator 向内建 CQRS 运行时迁移的方向一致,可读性也更好。


469-490: 命令/查询签名调整与 CQRS 过渡兼容性良好

这里对 SendCommand<TResult>SendQuery<TResult> 的类型引用更新保持了测试桩接口形状稳定,和前面的 CQRS 签名统一方向一致。

Comment thread docs/zh-CN/core/cqrs.md Outdated
Comment thread GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
Comment thread GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs
@GeWuYou GeWuYou changed the title Refactor/cqrs architecture decoupling todo 2 Replace Mediator pattern with CQRS pipeline behavior registration Apr 14, 2026
- 新增 CQRS 核心概念、命令查询处理器使用指南
- 添加管道行为、流式处理和最佳实践说明
- 实现 CQRS 协程扩展方法支持异步命令执行
- 添加 ContextAware 接口的 CQRS 命令查询扩展
- 集成 Microsoft DI 容器依赖注入支持
- 补充架构模块行为测试验证功能完整性
- 扩展 GameContext 测试用例提高代码覆盖率

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
docs/zh-CN/core/cqrs.md (1)

223-226: 建议补充“其他程序集接入”的最小可运行示例。

Line 223 目前只有原则性描述,缺少具体 API/接入点示例;迁移用户仍不清楚要在何处、如何把额外程序集并入处理器扫描。建议在此处追加一段最小示例(含迁移提示:何时继续保留 RegisterMediatorBehavior 兼容名)。

📌 建议补充的文档片段(示例)
-如果处理器位于其他模块或扩展程序集中,需要额外接入对应程序集的处理器注册,而不是依赖默认扫描。
+如果处理器位于其他模块或扩展程序集中,需要在架构初始化阶段显式接入这些程序集的处理器注册,而不是依赖默认扫描。
+
+例如(伪代码,按你项目实际 API 调整):
+
+```csharp
+protected override void OnInitialize()
+{
+    RegisterCqrsPipelineBehavior<LoggingBehavior<,>>();
+
+    // 默认扫描:当前架构程序集 + GFramework.Core
+    // 额外接入:模块/扩展程序集
+    // RegisterCqrsHandlersFrom(typeof(InventoryModuleMarker).Assembly);
+    // RegisterCqrsHandlersFrom(typeof(CombatModuleMarker).Assembly);
+}
+```
+
+迁移说明:`RegisterCqrsPipelineBehavior<TBehavior>()` 为推荐入口,
+`RegisterMediatorBehavior<TBehavior>()` 仅用于兼容旧代码。

As per coding guidelines "For integration-oriented features such as the AI-First config system, documentation MUST cover project directory layout, file conventions, required project/package wiring, minimal working usage example, and migration/compatibility notes".

🤖 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 223 - 226, Add a minimal runnable
example and migration note showing how to include handlers from other
assemblies: instruct the reader to override OnInitialize, call
RegisterCqrsPipelineBehavior<TBehavior>() (e.g., LoggingBehavior<,>) and
demonstrate using RegisterCqrsHandlersFrom with sample assembly marker types
(e.g., InventoryModuleMarker, CombatModuleMarker) to pull in external modules,
and append a brief migration note that RegisterCqrsPipelineBehavior<TBehavior>()
is the preferred entry while RegisterMediatorBehavior<TBehavior>() remains as a
compatibility alias.
GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs (1)

34-93: 建议补充“空参数 + 取消路径”用例,覆盖公开契约边界。

当前已覆盖 faulted/回调路径,但 ArgumentNullException 契约与取消状态行为还没有测试,后续重构时容易回归。

As per coding guidelines **/*.{cs,csproj}: Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical.

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

In `@GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs` around lines
34 - 93, Add two unit tests to CqrsCoroutineExtensionsTests targeting
CqrsCoroutineExtensions.SendCommandCoroutine: one to assert
ArgumentNullException is thrown when required parameters are null (e.g., pass
null for contextAware and/or command and call SendCommandCoroutine) and another
to assert cancellation behavior when the underlying MockContext.SendAsync
completes canceled (simulate by returning a canceled ValueTask or
Task.FromCanceled/throwing OperationCanceledException), verifying the coroutine
yields then either propagates an OperationCanceledException on MoveNext or
invokes the provided error callback with the cancellation exception; use
TestContextAware and its MockContext.Setup(ctx => ctx.SendAsync(...)) to
simulate the canceled task and assert the correct exception type is observed and
not wrapped in AggregateException.
🤖 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.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs`:
- Around line 103-114: Add XML documentation comments to the public members of
the TestContextAware class: the MockContext property, the GetContext() method,
and the SetContext(IArchitectureContext context) method. For each member add a
/// <summary> describing its purpose; for GetContext include a <returns>
describing the returned IArchitectureContext; for SetContext include a <param
name="context"> describing the parameter; include <remarks> if any behavioral
notes are needed and follow the repository's XML doc conventions (include
<exception> only if the member can throw). Target the members named MockContext,
GetContext, and SetContext.

In `@GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs`:
- Around line 42-49: The code only checks task.IsFaulted and treats non-faulted
tasks as successful, which misclassifies canceled tasks; update
CqrsCoroutineExtensions to detect task.IsCanceled before the IsFaulted check and
handle it by creating or using a TaskCanceledException (or
OperationCanceledException) and either invoking onError(exception) if onError !=
null or throwing the cancellation exception otherwise, then exit the coroutine;
keep the existing fault handling (using task.Exception?.InnerException) for
IsFaulted cases.

In `@GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs`:
- Around line 6-39: The XML docs for the public class
ContextAwareCqrsCommandExtensions and its public methods
SendCommand<TResponse>(this IContextAware, ICommand<TResponse>) and the async
SendCommand<TResponse>(this IContextAware, ICommand<TResponse>,
CancellationToken) are missing <remarks> blocks; add brief <remarks> to each
declaration describing usage boundaries and compatibility (e.g., note the sync
SendCommand is discouraged and only for compatibility, thread-safety or context
propagation considerations, and any cancellation semantics for the async
overload) so the class and both methods comply with the repository XML-doc
requirements.

---

Nitpick comments:
In `@docs/zh-CN/core/cqrs.md`:
- Around line 223-226: Add a minimal runnable example and migration note showing
how to include handlers from other assemblies: instruct the reader to override
OnInitialize, call RegisterCqrsPipelineBehavior<TBehavior>() (e.g.,
LoggingBehavior<,>) and demonstrate using RegisterCqrsHandlersFrom with sample
assembly marker types (e.g., InventoryModuleMarker, CombatModuleMarker) to pull
in external modules, and append a brief migration note that
RegisterCqrsPipelineBehavior<TBehavior>() is the preferred entry while
RegisterMediatorBehavior<TBehavior>() remains as a compatibility alias.

In `@GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs`:
- Around line 34-93: Add two unit tests to CqrsCoroutineExtensionsTests
targeting CqrsCoroutineExtensions.SendCommandCoroutine: one to assert
ArgumentNullException is thrown when required parameters are null (e.g., pass
null for contextAware and/or command and call SendCommandCoroutine) and another
to assert cancellation behavior when the underlying MockContext.SendAsync
completes canceled (simulate by returning a canceled ValueTask or
Task.FromCanceled/throwing OperationCanceledException), verifying the coroutine
yields then either propagates an OperationCanceledException on MoveNext or
invokes the provided error callback with the cancellation exception; use
TestContextAware and its MockContext.Setup(ctx => ctx.SendAsync(...)) to
simulate the canceled task and assert the correct exception type is observed and
not wrapped in AggregateException.
🪄 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: 6aa83c2c-a6af-40aa-94e9-8f87bf997625

📥 Commits

Reviewing files that changed from the base of the PR and between 115fe65 and 088f02d.

📒 Files selected for processing (13)
  • GFramework.Core.Abstractions/Architectures/IArchitecture.cs
  • GFramework.Core.Abstractions/Ioc/IIocContainer.cs
  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core.Tests/GlobalUsings.cs
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs
  • GFramework.Core/GlobalUsings.cs
  • GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs
  • docs/zh-CN/core/cqrs.md
✅ Files skipped from review due to trivial changes (5)
  • GFramework.Core/GlobalUsings.cs
  • GFramework.Core.Tests/GlobalUsings.cs
  • GFramework.Core/Extensions/ContextAwareCqrsQueryExtensions.cs
  • GFramework.Godot/Coroutine/ContextAwareCoroutineExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsExtensions.cs
🚧 Files skipped from review as they are similar to previous changes (4)
  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core.Abstractions/Architectures/IArchitecture.cs
  • GFramework.Core.Abstractions/Ioc/IIocContainer.cs
  • GFramework.Core.Tests/Architectures/GameContextTests.cs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (4)
**/*.cs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> where applicable
Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, and edge cases
Core framework components (Architecture, Module, System, Context, Registry, Service Module, Lifecycle types) MUST include high-level explanations of responsibilities, lifecycle, interactions, and design rationale
Generated logic and source generator pipelines MUST explain what is generated, why it is generated, semantic assumptions, and diagnostic or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling
Do not rely on implicit imports; declare every required using explicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, constants use PascalCase; interfaces use I prefix; parameters and locals use camelCase; private fields use _camelCase
Use 4 spaces for indentation (not tabs), use Allman braces, and keep using directives at the top of the file sorted consistently
Prefer one primary type per file unless the surrounding project already uses a different local pattern
Keep a single source file under roughly 800-1000 lines; if a file grows beyond that range, check whether responsibilities should be split before continuing
Keep line length readable, with around 120 characters as the preferred upper bound
Prefer explicit, readable code over clever shorthand in framework internals
Match existing async patterns and naming conventions (Async suffix for asynchronous methods) in C#
Avoid hidden side effects in property getters, constructors, and ...

Files:

  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
**/*.{cs,csproj}

📄 CodeRabbit inference engine (AGENTS.md)

Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical

Files:

  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
docs/**/*.md

📄 CodeRabbit inference engine (AGENTS.md)

docs/**/*.md: Update 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
For integration-oriented features such as the AI-First config system, documentation MUST cover project directory layout, file conventions, required project/package wiring, minimal working usage example, and migration/compatibility notes

Organize documentation in docs/ directory with Chinese content in docs/zh-CN/, covering Getting Started, module capabilities (Core, Game, Godot, ECS), Source Generator usage, tutorials, best practices, and troubleshooting

Files:

  • docs/zh-CN/core/cqrs.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/core/cqrs.md
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-05T15:30:46.211Z
Learning: Implement CQRS pattern (Command Query Responsibility Segregation) with support for both synchronous and asynchronous execution, using Mediator pattern integrated via source code generators
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-14T23:34:39.542Z
Learning: Follow all coding rules strictly as defined in AGENTS.md
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-14T23:34:39.542Z
Learning: Abstractions projects must contain only interfaces and contract definitions, without runtime implementation logic
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-14T23:34:39.542Z
Learning: Maintain separation between Abstractions projects (netstandard2.1), Core/Game/Ecs.Arch implementations (net8.0;net9.0;net10.0), Godot integration layer, and SourceGenerators layer
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-14T23:34:39.542Z
Learning: Design the framework with clear module boundaries, composable service registration, stable abstraction contracts, and appropriate source code generation automation to support long-term evolution as a game development foundation framework
📚 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: Applies to **/*.cs : ContextAwareGenerator must automatically implement IContextAware boilerplate logic for classes decorated with [ContextAware] attribute

Applied to files:

  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.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.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.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: Implement Coroutine system based on IYieldInstruction and scheduler abstractions, supporting wait patterns for time, events, and task completion

Applied to files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.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: Implement CQRS pattern (Command Query Responsibility Segregation) with support for both synchronous and asynchronous execution, using Mediator pattern integrated via source code generators

Applied to files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
  • docs/zh-CN/core/cqrs.md
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
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

Applied to files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to docs/zh-CN/**/*.md : When a feature is added, removed, renamed, or substantially refactored, contributors MUST update or create the corresponding user-facing integration documentation in `docs/zh-CN/` in the same change

Applied to files:

  • docs/zh-CN/core/cqrs.md
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to **/*.cs : Core framework components (Architecture, Module, System, Context, Registry, Service Module, Lifecycle types) MUST include high-level explanations of responsibilities, lifecycle, interactions, and design rationale

Applied to files:

  • docs/zh-CN/core/cqrs.md
🔇 Additional comments (2)
docs/zh-CN/core/cqrs.md (1)

207-223: 默认扫描范围说明已修正,方向正确。

Line 207 与 Line 218-223 明确了“默认仅扫描当前架构程序集 + GFramework.Core 程序集”,并补充了跨模块处理器需额外接入,已避免先前“自动注册范围过宽”的误导。

GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs (1)

21-49: 参数防御与 CQRS 委托实现清晰,保持这个方向。

Line 23-24、Line 45-46 的空值校验到位,Line 26/48 直接委托到上下文命令执行,避免了重复逻辑;异步方法直接返回 ValueTask<TResponse> 也比较高效。

Comment thread GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
Comment thread GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs Outdated
Comment thread GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
- 实现 CqrsCoroutineExtensions 扩展类,提供协程方式发送 CQRS 命令的功能
- 添加 SendCommandCoroutine 方法支持命令异步执行与异常处理
- 实现取消操作的特殊处理逻辑,区分取消、失败和成功状态
- 添加 ContextAwareCqrsCommandExtensions 扩展类,提供同步和异步命令发送方法
- 增加对 TaskCanceledException 的专门处理机制
- 完善相关单元测试,验证取消操作的异常处理行为

@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

🧹 Nitpick comments (1)
GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs (1)

46-65: 为取消/故障三态分支补充行内注释以降低维护误改风险。

这段状态分流和异常传播逻辑属于非平凡路径,建议在关键判断处加简短行内注释,明确“为何先判取消、为何使用 ExceptionDispatchInfo”。

建议补丁
         if (task.IsCanceled)
         {
+            // 取消态与成功态区分:协程层统一映射为 TaskCanceledException。
             var canceledException = new TaskCanceledException(task);
             if (onError != null)
             {
                 onError.Invoke(canceledException);
                 yield break;
             }

+            // 保留原始抛出栈,避免调试时丢失异常来源。
             ExceptionDispatchInfo.Capture(canceledException).Throw();
         }

         if (!task.IsFaulted)
             yield break;

+        // 优先解包业务异常,避免直接暴露 AggregateException。
         var exception = task.Exception!.InnerException ?? task.Exception;
         if (onError != null)
             onError.Invoke(exception);
         else
+            // 继续保留原始栈信息。
             ExceptionDispatchInfo.Capture(exception).Throw();

As per coding guidelines **/*.cs: Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, and edge cases.

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

In `@GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs` around lines
46 - 65, Add short inline comments in CqrsCoroutineExtensions.cs around the
non-trivial task-status branching to explain the rationale: annotate the
task.IsCanceled branch to state we handle cancellation first to avoid treating
cancellation as a fault, note why we create and pass a TaskCanceledException to
onError, document the use of ExceptionDispatchInfo.Capture(...).Throw() to
preserve the original stack trace when rethrowing, and comment the
task.IsFaulted branch to explain using Exception.InnerException ?? Exception to
prefer the original inner error. Place comments next to the checks and the
onError vs rethrow paths (the IsCanceled block, the ExceptionDispatchInfo calls,
and the IsFaulted / InnerException selection) to reduce risk of future
accidental changes.
🤖 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.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs`:
- Around line 61-65: The method in CqrsCoroutineExtensions.cs currently rethrows
the task's underlying exception via ExceptionDispatchInfo when onError is null,
but its XML docs only list ArgumentNullException and TaskCanceledException;
update the XML documentation for the public/internal method (the extension
method in CqrsCoroutineExtensions) to include the fault-branch exception
contract by adding <exception> tags for the rethrown exceptions (e.g.
System.Exception and/or System.AggregateException as appropriate to the
task.Exception!.InnerException behavior) and retain the existing <exception
cref="System.Threading.Tasks.TaskCanceledException"> and <exception
cref="System.ArgumentNullException"> entries so the doc accurately reflects that
ExceptionDispatchInfo.Capture(...).Throw() may surface the inner exception
types.

---

Nitpick comments:
In `@GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs`:
- Around line 46-65: Add short inline comments in CqrsCoroutineExtensions.cs
around the non-trivial task-status branching to explain the rationale: annotate
the task.IsCanceled branch to state we handle cancellation first to avoid
treating cancellation as a fault, note why we create and pass a
TaskCanceledException to onError, document the use of
ExceptionDispatchInfo.Capture(...).Throw() to preserve the original stack trace
when rethrowing, and comment the task.IsFaulted branch to explain using
Exception.InnerException ?? Exception to prefer the original inner error. Place
comments next to the checks and the onError vs rethrow paths (the IsCanceled
block, the ExceptionDispatchInfo calls, and the IsFaulted / InnerException
selection) to reduce risk of future accidental changes.
🪄 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: 2dc86310-00e9-4036-80cc-695e30882ecc

📥 Commits

Reviewing files that changed from the base of the PR and between 088f02d and 5a2981a.

📒 Files selected for processing (3)
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
🚧 Files skipped from review as they are similar to previous changes (2)
  • GFramework.Core.Tests/Coroutine/CqrsCoroutineExtensionsTests.cs
  • GFramework.Core/Extensions/ContextAwareCqrsCommandExtensions.cs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
**/*.cs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> where applicable
Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, and edge cases
Core framework components (Architecture, Module, System, Context, Registry, Service Module, Lifecycle types) MUST include high-level explanations of responsibilities, lifecycle, interactions, and design rationale
Generated logic and source generator pipelines MUST explain what is generated, why it is generated, semantic assumptions, and diagnostic or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling
Do not rely on implicit imports; declare every required using explicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, constants use PascalCase; interfaces use I prefix; parameters and locals use camelCase; private fields use _camelCase
Use 4 spaces for indentation (not tabs), use Allman braces, and keep using directives at the top of the file sorted consistently
Prefer one primary type per file unless the surrounding project already uses a different local pattern
Keep a single source file under roughly 800-1000 lines; if a file grows beyond that range, check whether responsibilities should be split before continuing
Keep line length readable, with around 120 characters as the preferred upper bound
Prefer explicit, readable code over clever shorthand in framework internals
Match existing async patterns and naming conventions (Async suffix for asynchronous methods) in C#
Avoid hidden side effects in property getters, constructors, and ...

Files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
**/*.{cs,csproj}

📄 CodeRabbit inference engine (AGENTS.md)

Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical

Files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
**/GFramework.Core/**/*.cs

📄 CodeRabbit inference engine (CLAUDE.md)

Apply LoggerGenerator attribute [Log] to automatically generate log fields and logging helper methods

Apply PriorityGenerator attribute [Priority] to automatically generate priority comparison implementations

Apply EnumExtensionsGenerator attribute [GenerateEnumExtensions] to automatically generate enum extension capabilities

Apply ContextAwareGenerator attribute [ContextAware] to automatically implement IContextAware boilerplate logic

Files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-05T15:30:46.211Z
Learning: Implement CQRS pattern (Command Query Responsibility Segregation) with support for both synchronous and asynchronous execution, using Mediator pattern integrated via source code generators
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:19:00.159Z
Learning: Follow the Architecture / Model / System / Utility four-layer structure pattern for framework core implementation
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:19:00.159Z
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-15T00:19:00.159Z
Learning: Use IContextAware interface and SetContext(IArchitectureContext) method for unified context propagation across components
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:19:00.159Z
Learning: Separate IModel for data and state layer, ISystem for business logic and command execution, and IUtility for stateless tools in C# implementation files
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:19:00.159Z
Learning: Organize lifecycle management through ArchitectureLifecycle, ArchitectureComponentRegistry, and ArchitectureModules components
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:19:00.159Z
Learning: Implement CQRS pattern with built-in runtime, behavior pipelines, and automatic handler registration in command and query execution
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:19:00.159Z
Learning: Use type-safe EventBus with support for event publishing, subscription, priority, filters, and weak reference subscription
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:19:00.159Z
Learning: Implement BindableProperty as a reactive property model for value change notifications
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:19:00.159Z
Learning: Implement frame-driven Coroutine system based on IYieldInstruction and scheduler abstraction
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:19:00.159Z
Learning: Use MicrosoftDiContainer wrapping Microsoft.Extensions.DependencyInjection for unified component registration and service resolution
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:19:00.159Z
Learning: Use IServiceModule pattern to register built-in services such as EventBus, CommandExecutor, QueryExecutor into Architecture
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:19:00.159Z
Learning: Organize repository structure with abstraction layer + implementation layer + integration layer + generator layer
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:19:00.159Z
Learning: Maintain documentation in docs/ with Chinese content in docs/zh-CN/ covering installation, module capabilities, source generators, and best practices
📚 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: Implement Coroutine system based on IYieldInstruction and scheduler abstractions, supporting wait patterns for time, events, and task completion

Applied to files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
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

Applied to files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.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.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs

Comment thread GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
GeWuYou added 2 commits April 15, 2026 08:24
- 将TaskCanceledException更改为Exception以反映实际抛出的异常类型
- 更新异常描述以准确说明在未提供onError时的行为
- 修正文档以反映底层原始异常的传递机制
- 添加 TaskCanceledException 映射以统一取消状态处理
- 保留原始异常调用栈以避免调试时丢失异常来源
- 优先解包业务异常以避免直接暴露 AggregateException
- 使用 ExceptionDispatchInfo.Capture 确保异常栈信息完整

@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.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs (1)

26-32: ⚠️ Potential issue | 🟡 Minor

请补充 TaskCanceledException 的 XML 异常契约。

当前方法在取消且 onError == null 时会抛出 TaskCanceledException(Line 46-58),但文档仅声明了 ArgumentNullExceptionException,公开 API 文档与实际行为不完全一致。

建议补丁
     /// <exception cref="Exception">
     ///     当底层命令调度失败且未提供 <paramref name="onError" /> 时,抛出底层原始异常。
     /// </exception>
+    /// <exception cref="TaskCanceledException">
+    ///     当底层命令调度被取消且未提供 <paramref name="onError" /> 时抛出。
+    /// </exception>
     /// <remarks>

As per coding guidelines **/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> where applicable.

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

In `@GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs` around lines
26 - 32, Add an <exception cref="TaskCanceledException"> XML comment to the
public extension method in CqrsCoroutineExtensions (the method that accepts the
onError callback and currently documents ArgumentNullException and Exception) to
reflect that when cancellation occurs and onError == null the method throws
TaskCanceledException (see logic around lines 46-58); include a short
description clarifying it is thrown to unify cancellation semantics so callers
know cancellation is represented by TaskCanceledException.
🤖 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.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs`:
- Around line 26-32: Add an <exception cref="TaskCanceledException"> XML comment
to the public extension method in CqrsCoroutineExtensions (the method that
accepts the onError callback and currently documents ArgumentNullException and
Exception) to reflect that when cancellation occurs and onError == null the
method throws TaskCanceledException (see logic around lines 46-58); include a
short description clarifying it is thrown to unify cancellation semantics so
callers know cancellation is represented by TaskCanceledException.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 29020727-29c9-48eb-8724-d4679d011bcc

📥 Commits

Reviewing files that changed from the base of the PR and between 5a2981a and 4c0a99d.

📒 Files selected for processing (1)
  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*.cs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with <summary>, <param>, <returns>, <exception>, and <remarks> where applicable
Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, and edge cases
Core framework components (Architecture, Module, System, Context, Registry, Service Module, Lifecycle types) MUST include high-level explanations of responsibilities, lifecycle, interactions, and design rationale
Generated logic and source generator pipelines MUST explain what is generated, why it is generated, semantic assumptions, and diagnostic or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling
Do not rely on implicit imports; declare every required using explicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace pattern GFramework.{Module}.{Feature} with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, constants use PascalCase; interfaces use I prefix; parameters and locals use camelCase; private fields use _camelCase
Use 4 spaces for indentation (not tabs), use Allman braces, and keep using directives at the top of the file sorted consistently
Prefer one primary type per file unless the surrounding project already uses a different local pattern
Keep a single source file under roughly 800-1000 lines; if a file grows beyond that range, check whether responsibilities should be split before continuing
Keep line length readable, with around 120 characters as the preferred upper bound
Prefer explicit, readable code over clever shorthand in framework internals
Match existing async patterns and naming conventions (Async suffix for asynchronous methods) in C#
Avoid hidden side effects in property getters, constructors, and ...

Files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
**/*.{cs,csproj}

📄 CodeRabbit inference engine (AGENTS.md)

Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical

Files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-05T15:30:46.211Z
Learning: Implement CQRS pattern (Command Query Responsibility Segregation) with support for both synchronous and asynchronous execution, using Mediator pattern integrated via source code generators
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
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-15T00:26:32.804Z
Learning: IArchitecture must serve 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-15T00:26:32.804Z
Learning: IContextAware must provide unified context access interface with components receiving architecture context through SetContext(IArchitectureContext) method
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: IModel must handle data and state management responsible for long-term state and business data modeling
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: ISystem must handle business logic responsible for command execution, flow orchestration, and rule implementation
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: IUtility must provide stateless tool utilities reusable across other framework layers
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: ArchitectureLifecycle component must manage lifecycle phases (Init, Ready, Destroy), phase transitions, and lifecycle hooks
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: ArchitectureComponentRegistry component must manage registration and resolution of Model, System, and Utility components
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: ArchitectureModules component must manage module installation, service module integration, and extension point registration
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: IArchitectureContext and related Provider types must be responsible for context propagation between framework components enabling unified architecture service access
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: Implement CQRS pattern with command and query separation supporting synchronous and asynchronous execution with internal CQRS runtime, behavior pipeline, and automatic handler registration
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: Implement type-safe EventBus supporting event publishing, subscription, priority levels, filters, and weak reference subscriptions
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: Implement BindableProperty reactive property model supporting value change notifications to drive UI or business layer updates
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: Implement frame-driven Coroutine system based on IYieldInstruction and scheduler abstraction supporting waiting for time, events, and task completion
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: Implement IoC through MicrosoftDiContainer wrapping Microsoft.Extensions.DependencyInjection for unified component registration and service resolution
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: Implement Service Modules using IServiceModule pattern for registering built-in services such as EventBus, CommandExecutor, and QueryExecutor with Architecture
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: Organize repository with abstraction layers (Core.Abstractions, Game.Abstractions), implementation layers (Core, Game), integration layers (Godot, Ecs.Arch), and source generator layers
Learnt from: CR
URL: 
File: CLAUDE.md:undefined-undefined
Timestamp: 2026-04-15T00:26:32.804Z
Learning: Recommended documentation reading order is root README.md, then submodule README.md files, then specialized topics in docs/ directory
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
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

Applied to files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
Learning: Applies to **/*.cs : Add inline comments for non-trivial logic, concurrency/threading behavior, performance-sensitive paths, workarounds, compatibility constraints, and edge cases

Applied to files:

  • GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
📚 Learning: 2026-04-14T01:59:40.041Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-14T01:59:40.041Z
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.Core/Coroutine/Extensions/CqrsCoroutineExtensions.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.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs
🔇 Additional comments (1)
GFramework.Core/Coroutine/Extensions/CqrsCoroutineExtensions.cs (1)

42-68: 取消态/失败态映射与栈保留实现正确。

这里对 IsCanceledIsFaulted 的分支拆分清晰,且用 ExceptionDispatchInfo 保留抛出栈,协程语义与调试体验都比较稳健。

- 添加了TaskCanceledException异常说明文档
- 详细描述了命令调度取消时的异常情况
- 补充了底层命令调度相关的异常处理说明
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