From 98021f59e77e829f15cd571ed2bda01df1451596 Mon Sep 17 00:00:00 2001
From: gewuyou <95328647+GeWuYou@users.noreply.github.com>
Date: Thu, 30 Apr 2026 09:00:24 +0800
Subject: [PATCH] =?UTF-8?q?test(cqrs):=20=E8=A1=A5=E9=BD=90=20PR304=20?=
=?UTF-8?q?=E6=B5=8B=E8=AF=95=20XML=20=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 补齐上下文校验 handler 的 Handle 参数与返回 XML 注释
- 更新带 DispatchId 的测试请求与通知 XML 参数注释
- 记录 cqrs-rewrite 主题的本轮 PR review 跟进
---
.../Cqrs/CqrsDispatcherContextValidationTests.cs | 9 +++++++++
.../DispatcherNotificationContextRefreshNotification.cs | 1 +
.../Cqrs/DispatcherStreamContextRefreshRequest.cs | 1 +
.../todos/cqrs-rewrite-migration-tracking.md | 1 +
4 files changed, 12 insertions(+)
diff --git a/GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherContextValidationTests.cs b/GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherContextValidationTests.cs
index bf1998a9..bc12c773 100644
--- a/GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherContextValidationTests.cs
+++ b/GFramework.Cqrs.Tests/Cqrs/CqrsDispatcherContextValidationTests.cs
@@ -122,6 +122,9 @@ internal sealed class CqrsDispatcherContextValidationTests
///
/// 返回固定结果;当前测试只关心调用前的上下文校验。
///
+ /// 当前请求。
+ /// 取消令牌。
+ /// 固定整型结果。
public ValueTask Handle(ContextAwareRequest request, CancellationToken cancellationToken)
{
return ValueTask.FromResult(1);
@@ -138,6 +141,9 @@ internal sealed class CqrsDispatcherContextValidationTests
///
/// 返回已完成任务;当前测试只关心调用前的上下文校验。
///
+ /// 当前通知。
+ /// 取消令牌。
+ /// 已完成任务。
public ValueTask Handle(ContextAwareNotification notification, CancellationToken cancellationToken)
{
return ValueTask.CompletedTask;
@@ -154,6 +160,9 @@ internal sealed class CqrsDispatcherContextValidationTests
///
/// 返回一个最小流;当前测试只关心建流前的上下文校验。
///
+ /// 当前流请求。
+ /// 取消枚举时使用的取消令牌。
+ /// 包含单个固定元素的异步流。
public async IAsyncEnumerable Handle(
ContextAwareStreamRequest request,
[EnumeratorCancellation] CancellationToken cancellationToken)
diff --git a/GFramework.Cqrs.Tests/Cqrs/DispatcherNotificationContextRefreshNotification.cs b/GFramework.Cqrs.Tests/Cqrs/DispatcherNotificationContextRefreshNotification.cs
index f1f54dd2..faa3f5af 100644
--- a/GFramework.Cqrs.Tests/Cqrs/DispatcherNotificationContextRefreshNotification.cs
+++ b/GFramework.Cqrs.Tests/Cqrs/DispatcherNotificationContextRefreshNotification.cs
@@ -5,4 +5,5 @@ namespace GFramework.Cqrs.Tests.Cqrs;
///
/// 为 notification dispatch binding 上下文刷新回归提供带分发标识的最小通知。
///
+/// 当前分发的稳定标识,便于断言缓存 binding 复用时观察到的是同一次通知。
internal sealed record DispatcherNotificationContextRefreshNotification(string DispatchId) : INotification;
diff --git a/GFramework.Cqrs.Tests/Cqrs/DispatcherStreamContextRefreshRequest.cs b/GFramework.Cqrs.Tests/Cqrs/DispatcherStreamContextRefreshRequest.cs
index c8d69cfe..f453886e 100644
--- a/GFramework.Cqrs.Tests/Cqrs/DispatcherStreamContextRefreshRequest.cs
+++ b/GFramework.Cqrs.Tests/Cqrs/DispatcherStreamContextRefreshRequest.cs
@@ -5,4 +5,5 @@ namespace GFramework.Cqrs.Tests.Cqrs;
///
/// 为 stream dispatch binding 上下文刷新回归提供带分发标识的最小流请求。
///
+/// 当前分发的稳定标识,便于断言缓存 binding 复用时观察到的是同一次建流。
internal sealed record DispatcherStreamContextRefreshRequest(string DispatchId) : IStreamRequest;
diff --git a/ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md b/ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
index 65874cd5..1d539457 100644
--- a/ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
+++ b/ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
@@ -30,6 +30,7 @@ CQRS 迁移与收敛。
- 已完成一轮 `static lambda + state` 微收敛:`CqrsDispatcher` 与 `CqrsHandlerRegistrar` 现会在弱缓存 / 并发缓存入口优先使用无捕获工厂,继续压低热路径上的额外闭包分配
- 已补充 `CqrsReflectionFallbackAttribute` 叶子级合同测试,锁定空 marker、字符串 fallback 名称归一化、直接 `Type` fallback 归一化与空参数防御语义
- 已完成 `PR #304` review follow-up 收敛:`CqrsDispatcher` 现补齐 pipeline executor / continuation 缓存的线程模型文档,并把 request pipeline invoker 从按 `behaviorCount` 重复创建收敛为 binding 内复用
+ - 已补齐 `CqrsDispatcherContextValidationTests` 三个上下文校验 handler 的 XML `param` / `returns` 注释,以及 `DispatcherNotificationContextRefreshNotification`、`DispatcherStreamContextRefreshRequest` 的 `DispatchId` XML 参数注释,收敛上一轮 PR review 遗留的文档类 minor feedback
- 已收紧 CQRS / generator 回归测试的脆弱断言:日志断言改为语义匹配,precise runtime type lookup 回归改为锁定数组秩、外部类型查找与“未发射 fallback metadata”这些稳定语义
- 已为 dispatcher cache / context refresh / pipeline order 三组测试状态容器补齐并发保护,并将 `CqrsDispatcherCacheTests` 标记为 `NonParallelizable`,避免静态缓存与共享快照在并行测试中相互污染
- 中期上继续 `Phase 8` 主线:参考 `ai-libs/Mediator`,继续扩大 generator 覆盖,并选择下一个收益明确的 dispatch / invoker 反射收敛点