Feat/cqrs optimization#261
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 28 minutes and 53 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthrough源生成器收紧了对指针与函数指针泛型参数的精确引用判定并新增指针运行时解析路径;registrar 在程序集处理时改为本地映射去重与按类型支持接口缓存,并尝试使用动态方法生成已生成 registry 的激活工厂(失败时回退);新增多项回归测试与迁移记录更新。 Changes
Sequence Diagram(s)sequenceDiagram
participant Source as Source Generator
participant Spec as RuntimeTypeReferenceSpec
participant Generator as CqrsHandlerRegistryGenerator
participant Registrar as CqrsHandlerRegistrar
participant DI as IServiceCollection
Source->>Spec: Inspect generic argument type (pointer / function-pointer)
Spec-->>Source: Mark as non-referenceable OR create PointerElementTypeReference
Source->>Generator: Emit diagnostics (GF_Cqrs_001) or generate runtime resolution using PointerElementTypeReference
Registrar->>Registrar: Build HashSet<HandlerMapping> and query SupportedHandlerInterfacesCache
Registrar->>Generator: Request generated registry activation factory
Generator-->>Registrar: Return dynamic factory (or throw)
alt dynamic factory created
Registrar->>Registrar: Invoke dynamic factory -> instantiate registry
else fallback
Registrar->>Registrar: Use Reflection ConstructorInfo.Invoke -> instantiate registry
end
Registrar->>DI: Register handler service mappings (skip duplicates via HashSet)
代码审查工作量🎯 4 (Complex) | ⏱️ ~45 分钟 可能相关的PR
概览该PR收紧了CQRS源生成器对指针与函数指针泛型参数的精确运行时引用判定(将二者视为不可精确生成),在运行时类型重建中新增指针解析路径以支持生成时的 PointerElementTypeReference 与 .MakePointerType() 调用;在 registrar 中用预计算 HashSet 替换对 IServiceCollection 的逐项线性扫描以做去重,引入按 Type 缓存的支持接口发现并尝试通过动态方法(Reflection.Emit)生成已生成 registry 的激活工厂(失败时回退到反射);同时补充相关回归测试以覆盖私有构造器激活、缓存复用与重复类型跳过场景,并更新迁移/追踪文档记录。 改动
代码审查工作量(重复展示)🎯 4 (Complex) | ⏱️ ~45 分钟 可能相关的PR(重复展示)
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Test ResultsDetails
Insights
build-and-test: Run #899
🎉 All tests passed!Slowest Tests
± Comparison with run #883 at 04f2062 | 🎉 No failed tests detected across all runs. | 🍂 No flaky tests detected across all runs. | ⏱️ Measured over 7 runs. Github Test Reporter by CTRF 💚 |
✅
|
| Descriptor | Linter | Files | Fixed | Errors | Warnings | Elapsed time |
|---|---|---|---|---|---|---|
| dotnet-format | yes | 1 | no | 5.43s | ||
| ✅ REPOSITORY | gitleaks | yes | no | no | 7.05s | |
| ✅ REPOSITORY | trufflehog | yes | no | no | 6.41s |
Detailed Issues
⚠️ CSHARP / dotnet-format - 1 error
Welcome to .NET 9.0!
---------------------
SDK Version: 9.0.114
----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate, run 'dotnet dev-certs https --trust'
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Unhandled exception: System.Exception: Restore operation failed.
at Microsoft.CodeAnalysis.Tools.CodeFormatter.OpenMSBuildWorkspaceAsync(String solutionOrProjectPath, WorkspaceType workspaceType, Boolean noRestore, Boolean requiresSemantics, String binaryLogPath, Boolean logWorkspaceWarnings, ILogger logger, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Tools.CodeFormatter.FormatWorkspaceAsync(FormatOptions formatOptions, ILogger logger, CancellationToken cancellationToken, String binaryLogPath)
at Microsoft.CodeAnalysis.Tools.FormatCommandCommon.FormatAsync(FormatOptions formatOptions, ILogger`1 logger, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Tools.Commands.RootFormatCommand.FormatCommandDefaultHandler.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

Show us your support by starring ⭐ the repository
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs`:
- Around line 415-420: Reject pointer and function-pointer types early so the
generator never emits CQRS generic registrations for T* or delegate*; in
TryCreateRuntimeTypeReference(...) add an early check that if the incoming
symbol is IPointerTypeSymbol or IFunctionPointerTypeSymbol you return false
immediately (do not recurse into PointedAtType), and update
CanReferenceFromGeneratedRegistry(...) so its pointer and function-pointer
branches return false (again, do not attempt to inspect the pointed-at type).
Refer to the TryCreateRuntimeTypeReference and CanReferenceFromGeneratedRegistry
symbols when making these changes.
In `@GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs`:
- Around line 850-875: The test uses invalid generic type arguments
(HiddenResponse* and function pointer types) for IRequest<T> and
IRequestHandler<,> which cause C# compiler error CS0306; update the test so the
input source is a valid CQRS contract (e.g., change HiddenResponse* to a
non-pointer type like HiddenResponse and adjust HiddenHandler to
IRequestHandler<HiddenRequest, HiddenResponse>) OR explicitly assert that the
generator/compilation produces the expected diagnostics (check
GeneratedCompilationDiagnostics/GeneratorDiagnostics for CS0306) instead of
asserting successful compilation and a generated source; ensure assertions
around execution.GeneratedSources and the filename/content expectations only run
when the source is compilable (or when you intend to verify generation behavior
on invalid input, assert the diagnostics and document intent).
🪄 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: f9ebe85c-a29e-4b12-8bd0-cbe8d5b22ed6
📒 Files selected for processing (6)
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.csGFramework.Cqrs/Internal/CqrsHandlerRegistrar.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.mdai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
📜 Review details
🧰 Additional context used
📓 Path-based instructions (5)
**/Cqrs/**/*.cs
📄 CodeRabbit inference engine (CLAUDE.md)
Use CQRS (Command Query Responsibility Segregation) pattern with the Cqrs naming entry point instead of the historical Mediator alias
Files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.cs
**/*.cs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.cs: Apply [Log] attribute for automatic logging field and logging helper method generation
Apply [Priority] attribute for automatic priority comparison implementation generation
Apply [GenerateEnumExtensions] attribute to generate enumeration extension capabilities
Apply [ContextAware] attribute to automatically implement IContextAware boilerplate logic
**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with<summary>,<param>,<returns>,<exception>, and<remarks>where applicable. Comments must explain intent, contract, and usage constraints instead of restating syntax.
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds or compatibility constraints, and registration order or lifecycle sequencing.
Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives.
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling.
Follow the namespace patternGFramework.{Module}.{Feature}with PascalCase segments.
Use the following C# naming conventions: Types, methods, properties, events, and constants use PascalCase; interfaces useIprefix; parameters and locals use camelCase; private fields use_camelCase.
Do not rely on implicit imports. Declare every requiredusingexplicitly. Keepusingdirectives at the top of the file and sort them consistently.
Write null-safe code that respects nullable annotations instead of suppressing warnings by default. The project hasNullableenabled.
Use 4 spaces for indentation. Do not use tabs. Use Allman braces. Keep line length readable, around 120 characters as the preferred upper bound.
Prefer one primary type per...
Files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.Cqrs/Internal/CqrsHandlerRegistrar.csGFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.cs
ai-plan/public/**/*
📄 CodeRabbit inference engine (AGENTS.md)
ai-plan/public/**/*: Contributors MUST keep committedai-plan/public/**content safe to publish in Git history. Never write secrets, tokens, credentials, private keys, machine usernames, home-directory paths, hostnames, IP addresses, proprietary URLs, or other sensitive environment details into anyai-plan/**file.
Never record absolute file-system paths inai-plan/**; use repository-relative paths, branch names, PR numbers, or stable document identifiers instead.
Files:
ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.mdai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
ai-plan/public/*/traces/**/*
📄 CodeRabbit inference engine (AGENTS.md)
Contributors MUST maintain a matching execution trace under
ai-plan/public/<topic>/traces/for complex work. The trace should record the current date, key decisions, validation milestones, and the immediate next step. Update traces at each meaningful milestone before pausing or handing work off.
Files:
ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
ai-plan/public/*/todos/**/*
📄 CodeRabbit inference engine (AGENTS.md)
When working from a tracked implementation plan, contributors MUST update the corresponding tracking document under
ai-plan/public/<topic>/todos/in the same change. Updates MUST reflect completed work, newly discovered issues, validation results, and the next recommended recovery point. Tracking files are recovery entrypoints, not append-only changelogs, and MUST stay concise.
Files:
ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
🧠 Learnings (10)
📚 Learning: 2026-04-19T07:58:40.583Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-19T07:58:40.583Z
Learning: Applies to **/*.g.cs : Source generator changes MUST be covered by generator tests. Preserve snapshot-based verification patterns already used in the repository. When generator behavior changes intentionally, update snapshots together with the implementation.
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.cs
📚 Learning: 2026-04-17T11:35:08.762Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-17T11:35:08.762Z
Learning: Applies to **/*{Startup,Init,Register,Setup,Configure}*.cs : CQRS handler registration should use generated products from CqrsHandlerRegistryGenerator at runtime, falling back to reflection scanning when generation cannot cover cases; explicitly register handlers from non-default assemblies using RegisterCqrsHandlersFromAssembly(...) or RegisterCqrsHandlersFromAssemblies(...)
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.mdGFramework.Cqrs/Internal/CqrsHandlerRegistrar.csGFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.cs
📚 Learning: 2026-04-19T07:58:40.583Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-19T07:58:40.583Z
Learning: Applies to **/*.cs : Avoid hidden side effects in property getters, constructors, and registration helpers. Preserve deterministic behavior in registries, lifecycle orchestration, and generated outputs.
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Cqrs/Internal/CqrsHandlerRegistrar.csGFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.cs
📚 Learning: 2026-04-19T07:58:40.583Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-19T07:58:40.583Z
Learning: Applies to **/*.Tests.cs : When a public API defines multiple contract branches, tests MUST cover the meaningful variants, including null, empty, default, and filtered inputs when those branches change behavior. Regression fixes should include a test that fails before the fix and passes after it.
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.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.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.Cqrs/Internal/CqrsHandlerRegistrar.csGFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.cs
📚 Learning: 2026-04-16T13:25:59.124Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 235
File: GFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.cs:1-3
Timestamp: 2026-04-16T13:25:59.124Z
Learning: In the GeWuYou/GFramework repo, treat `global using NUnit.Framework;` as provided project-wide by `GFramework.SourceGenerators.Tests/GlobalUsings.cs` (via GlobalUsings.cs). Do not require or flag missing per-file `using NUnit.Framework;` directives in test `.cs` files under `GFramework.SourceGenerators.Tests/`, since the project-wide global usings already include NUnit (along with other common namespaces).
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-19T07:58:40.583Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-19T07:58:40.583Z
Learning: For any multi-step refactor, migration, or cross-module task, contributors MUST create or adopt a dedicated recovery document under `ai-plan/public/<topic>/todos/` before making substantive code changes. Recovery documents MUST record the current phase, the active recovery point identifier, known risks, and the next recommended resume step so another contributor or subagent can continue the work safely.
Applied to files:
ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
📚 Learning: 2026-04-19T07:58:40.583Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-19T07:58:40.583Z
Learning: Applies to ai-plan/public/*/todos/**/* : When working from a tracked implementation plan, contributors MUST update the corresponding tracking document under `ai-plan/public/<topic>/todos/` in the same change. Updates MUST reflect completed work, newly discovered issues, validation results, and the next recommended recovery point. Tracking files are recovery entrypoints, not append-only changelogs, and MUST stay concise.
Applied to files:
ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
📚 Learning: 2026-04-17T11:35:08.762Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-17T11:35:08.762Z
Learning: Applies to **/Cqrs/**/*.cs : Use CQRS (Command Query Responsibility Segregation) pattern with the Cqrs naming entry point instead of the historical Mediator alias
Applied to files:
GFramework.Cqrs/Internal/CqrsHandlerRegistrar.cs
📚 Learning: 2026-04-19T07:58:40.583Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-19T07:58:40.583Z
Learning: Applies to **/*.Tests.cs : Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical. Public API changes must be covered by unit or integration tests.
Applied to files:
GFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.cs
🪛 LanguageTool
ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
[grammar] ~7-~7: Ensure spelling is correct
Context: ... mapping 判定从逐条线性扫描 IServiceCollection 收敛为单次构建的本地映射索引 - reflection fallback 或重复类型输入场景下,后续 dup...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[grammar] ~17-~17: Ensure spelling is correct
Context: ...ported handler interface 元数据,reflection 注册路径现会复用已筛选且排序好的接口列表 - 同一 handler 类型跨容器重复注册时,不再重复执行 `GetInte...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🔇 Additional comments (4)
ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md (1)
10-20: 跟踪文档更新符合恢复入口要求。恢复点、已完成项、验证结果和下一步都已同步,且未看到不应进入
ai-plan/public/**的敏感环境信息。As per coding guidelines,
ai-plan/public/*/todos/**/*: tracking files must reflect completed work, newly discovered issues, validation results, and the next recommended recovery point.Also applies to: 33-52, 74-88
ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md (1)
3-46: Trace 与本轮 CQRS 收敛进度保持同步。记录了日期、关键决策、验证里程碑和后续恢复步骤,适合作为交接入口。
As per coding guidelines,
ai-plan/public/*/traces/**/*: traces should record the current date, key decisions, validation milestones, and the immediate next step.Also applies to: 57-59
GFramework.Cqrs/Internal/CqrsHandlerRegistrar.cs (1)
29-32: Registrar 缓存与去重改动看起来合理。本地
HashSet避免重复线性扫描,supported-interface 缓存和 generated-registry factory 都有卸载/回退语义说明,注册路径仍保持确定性。Also applies to: 168-226, 365-406, 490-490
GFramework.Cqrs.Tests/Cqrs/CqrsHandlerRegistrarTests.cs (1)
145-168: 新增 registrar 回归覆盖到位。私有无参构造 registry、supported-interface 缓存复用、重复 handler mapping 去重以及测试间缓存隔离都覆盖到了本轮实现变化。
Based on learnings, regression fixes should include a test that fails before the fix and passes after it.
Also applies to: 441-516, 518-583, 783-811
- 修复 CqrsHandlerRegistryGenerator 对 pointer 与 function pointer 的精确注册建模 - 补充生成器测试对输入源 CS0306 与 fallback 诊断的断言 - 更新 cqrs-rewrite 跟踪文档记录 PR #261 review follow-up
Summary
Test ResultsDetails
Insights
build-and-test: Run #905
🎉 All tests passed!Slowest Tests
± Comparison with run #899 at 582263c | 🎉 No failed tests detected across all runs. | 🍂 No flaky tests detected across all runs. | ⏱️ Measured over 8 runs. Github Test Reporter by CTRF 💚 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs (1)
988-998: 建议移除当前不可达的 pointer runtime-reference 建模分支。
TryCreateRuntimeTypeReference现在已经在入口拒绝IPointerTypeSymbol,所以PointerElementTypeReference、FromPointer(...)、.MakePointerType()发射分支和外部程序集递归检查在当前生成器路径里没有调用来源。保留这些分支会让后续维护者误以为 pointer precise registration 仍受支持。♻️ 可选清理方向
- if (runtimeTypeReference.PointerElementTypeReference is not null) - { - var pointedAtExpression = AppendRuntimeTypeReferenceResolution( - builder, - runtimeTypeReference.PointerElementTypeReference, - $"{variableBaseName}PointedAt", - reflectedArgumentNames, - indent); - - return $"{pointedAtExpression}.MakePointerType()"; - } - if (runtimeTypeReference.GenericTypeDefinitionReference is not null)- if (runtimeTypeReference.PointerElementTypeReference is not null && - ContainsExternalAssemblyTypeLookup(runtimeTypeReference.PointerElementTypeReference)) - { - return true; - } - if (runtimeTypeReference.GenericTypeDefinitionReference is not null &&- RuntimeTypeReferenceSpec? PointerElementTypeReference, RuntimeTypeReferenceSpec? GenericTypeDefinitionReference, ImmutableArray<RuntimeTypeReferenceSpec> GenericTypeArguments)- return new RuntimeTypeReferenceSpec(typeDisplayName, null, null, null, 0, null, null, + return new RuntimeTypeReferenceSpec(typeDisplayName, null, null, null, 0, null, ImmutableArray<RuntimeTypeReferenceSpec>.Empty);- public static RuntimeTypeReferenceSpec FromPointer(RuntimeTypeReferenceSpec pointedAtTypeReference) - { - return new RuntimeTypeReferenceSpec(null, null, null, null, 0, pointedAtTypeReference, null, - ImmutableArray<RuntimeTypeReferenceSpec>.Empty); - } -如果这是为后续非泛型 runtime type 场景预留的,请加一条注释说明当前 CQRS handler contract 路径不会调用它。
Also applies to: 1116-1120, 1160-1194
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs` around lines 988 - 998, The pointer-handling branch is unreachable because TryCreateRuntimeTypeReference now rejects IPointerTypeSymbol; remove the PointerElementTypeReference / FromPointer / .MakePointerType() branch in AppendRuntimeTypeReferenceResolution (and any related checks for pointer runtime references such as the sections around PointerElementTypeReference and calls to FromPointer/MakePointerType), or if you intend to reserve it for future non-generic runtime-type scenarios, replace the branch with a clear TODO comment stating that TryCreateRuntimeTypeReference eliminates IPointerTypeSymbol on the CQRS handler path so this code is currently unused; ensure references to runtimeTypeReference.PointerElementTypeReference, AppendRuntimeTypeReferenceResolution, FromPointer and MakePointerType are cleaned up or documented accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md`:
- Around line 39-48: Update the trace entry for "阶段:pointer precise runtime type
覆盖扩展(CQRS-REWRITE-RP-047)" to explicitly mark RP-047 as superseded by RP-050 and
avoid ambiguity: locate the paragraph referencing CqrsHandlerRegistryGenerator
and MakePointerType and append a clear statement like "This approach was
superseded/abandoned by RP-050 — do not revert to MakePointerType precise
registration," ensure the historical note explains that pointer/function pointer
behavior now uniformly uses fallback/diagnostic per RP-050, and add a brief
"Next step" line indicating RP-050 is the authoritative source for current
behavior (so future contributors won't reinstate RP-047).
---
Nitpick comments:
In `@GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs`:
- Around line 988-998: The pointer-handling branch is unreachable because
TryCreateRuntimeTypeReference now rejects IPointerTypeSymbol; remove the
PointerElementTypeReference / FromPointer / .MakePointerType() branch in
AppendRuntimeTypeReferenceResolution (and any related checks for pointer runtime
references such as the sections around PointerElementTypeReference and calls to
FromPointer/MakePointerType), or if you intend to reserve it for future
non-generic runtime-type scenarios, replace the branch with a clear TODO comment
stating that TryCreateRuntimeTypeReference eliminates IPointerTypeSymbol on the
CQRS handler path so this code is currently unused; ensure references to
runtimeTypeReference.PointerElementTypeReference,
AppendRuntimeTypeReferenceResolution, FromPointer and MakePointerType are
cleaned up or documented accordingly.
🪄 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: f3ba3d1e-d82e-4c42-b7df-05bed09b9499
📒 Files selected for processing (4)
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.mdai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
🚧 Files skipped from review as they are similar to previous changes (1)
- GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (5)
**/Cqrs/**/*.cs
📄 CodeRabbit inference engine (CLAUDE.md)
Use CQRS (Command Query Responsibility Segregation) pattern with the Cqrs naming entry point instead of the historical Mediator alias
Files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
**/*.cs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.cs: Apply [Log] attribute for automatic logging field and logging helper method generation
Apply [Priority] attribute for automatic priority comparison implementation generation
Apply [GenerateEnumExtensions] attribute to generate enumeration extension capabilities
Apply [ContextAware] attribute to automatically implement IContextAware boilerplate logic
**/*.cs: All public, protected, and internal types and members MUST include XML documentation comments (///) with<summary>,<param>,<returns>,<exception>, and<remarks>where applicable. Comments must explain intent, contract, and usage constraints instead of restating syntax.
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds or compatibility constraints, and registration order or lifecycle sequencing.
Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives.
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling.
Follow the namespace patternGFramework.{Module}.{Feature}with PascalCase segments.
Use the following C# naming conventions: Types, methods, properties, events, and constants use PascalCase; interfaces useIprefix; parameters and locals use camelCase; private fields use_camelCase.
Do not rely on implicit imports. Declare every requiredusingexplicitly. Keepusingdirectives at the top of the file and sort them consistently.
Write null-safe code that respects nullable annotations instead of suppressing warnings by default. The project hasNullableenabled.
Use 4 spaces for indentation. Do not use tabs. Use Allman braces. Keep line length readable, around 120 characters as the preferred upper bound.
Prefer one primary type per...
Files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
ai-plan/public/**/*
📄 CodeRabbit inference engine (AGENTS.md)
ai-plan/public/**/*: Contributors MUST keep committedai-plan/public/**content safe to publish in Git history. Never write secrets, tokens, credentials, private keys, machine usernames, home-directory paths, hostnames, IP addresses, proprietary URLs, or other sensitive environment details into anyai-plan/**file.
Never record absolute file-system paths inai-plan/**; use repository-relative paths, branch names, PR numbers, or stable document identifiers instead.
Files:
ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.mdai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
ai-plan/public/*/todos/**/*
📄 CodeRabbit inference engine (AGENTS.md)
When working from a tracked implementation plan, contributors MUST update the corresponding tracking document under
ai-plan/public/<topic>/todos/in the same change. Updates MUST reflect completed work, newly discovered issues, validation results, and the next recommended recovery point. Tracking files are recovery entrypoints, not append-only changelogs, and MUST stay concise.
Files:
ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
ai-plan/public/*/traces/**/*
📄 CodeRabbit inference engine (AGENTS.md)
Contributors MUST maintain a matching execution trace under
ai-plan/public/<topic>/traces/for complex work. The trace should record the current date, key decisions, validation milestones, and the immediate next step. Update traces at each meaningful milestone before pausing or handing work off.
Files:
ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
🧠 Learnings (7)
📚 Learning: 2026-04-17T11:35:08.762Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-17T11:35:08.762Z
Learning: Applies to **/*{Startup,Init,Register,Setup,Configure}*.cs : CQRS handler registration should use generated products from CqrsHandlerRegistryGenerator at runtime, falling back to reflection scanning when generation cannot cover cases; explicitly register handlers from non-default assemblies using RegisterCqrsHandlersFromAssembly(...) or RegisterCqrsHandlersFromAssemblies(...)
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
📚 Learning: 2026-04-19T07:58:40.583Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-19T07:58:40.583Z
Learning: Applies to **/*.g.cs : Source generator changes MUST be covered by generator tests. Preserve snapshot-based verification patterns already used in the repository. When generator behavior changes intentionally, update snapshots together with the implementation.
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
📚 Learning: 2026-04-19T07:58:40.583Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-19T07:58:40.583Z
Learning: Applies to **/*.cs : Avoid hidden side effects in property getters, constructors, and registration helpers. Preserve deterministic behavior in registries, lifecycle orchestration, and generated outputs.
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md
📚 Learning: 2026-04-06T12:45:43.921Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:43.921Z
Learning: In the GeWuYou/GFramework repository, C# files may omit explicit `using System*` imports because the project-wide `GlobalUsings.cs` (referenced via manual global `using` directives) supplies common namespaces (e.g., `System`, `System.Threading`, `System.Threading.Tasks`). During code review, do not flag missing `using System...` directives in `.cs` files as long as `GlobalUsings.cs` is present/used to provide those namespaces.
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-19T07:58:40.583Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-19T07:58:40.583Z
Learning: For any multi-step refactor, migration, or cross-module task, contributors MUST create or adopt a dedicated recovery document under `ai-plan/public/<topic>/todos/` before making substantive code changes. Recovery documents MUST record the current phase, the active recovery point identifier, known risks, and the next recommended resume step so another contributor or subagent can continue the work safely.
Applied to files:
ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.mdai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
📚 Learning: 2026-04-19T07:58:40.583Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-19T07:58:40.583Z
Learning: Applies to ai-plan/public/*/todos/**/* : When working from a tracked implementation plan, contributors MUST update the corresponding tracking document under `ai-plan/public/<topic>/todos/` in the same change. Updates MUST reflect completed work, newly discovered issues, validation results, and the next recommended recovery point. Tracking files are recovery entrypoints, not append-only changelogs, and MUST stay concise.
Applied to files:
ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.mdai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
📚 Learning: 2026-04-19T07:58:40.583Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-19T07:58:40.583Z
Learning: Applies to ai-plan/public/*/traces/**/* : Contributors MUST maintain a matching execution trace under `ai-plan/public/<topic>/traces/` for complex work. The trace should record the current date, key decisions, validation milestones, and the immediate next step. Update traces at each meaningful milestone before pausing or handing work off.
Applied to files:
ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
🪛 LanguageTool
ai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md
[grammar] ~9-~9: Ensure spelling is correct
Context: ...e(),而测试只校验生成源诊断,未显式暴露输入源 CS0306- 已在GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegist...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[grammar] ~12-~12: Ensure spelling is correct
Context: ...言 CS0306 与 fallback / diagnostic 结果 - 定向验证已通过: - dotnet test GFramework.SourceGenerators.Tests/GFramework.SourceGenerators.Tests.csproj -c Release --no-restore -p:RestoreFallbackFolders= -m:1 -nodeReuse:false --filter "FullyQualifiedName~Reports_Compilation_Error_And_Skips_Precise_Registration_For_Hidden_Pointer_Response|FullyQualifiedName~Reports_Diagnostic_And_Skips_Registry_When_Fallback_Metadata_Is_Required_But_Runtime_Contract_Lacks_Fallback_Attribute|FullyQualifiedName~Emits_Assembly_Level_Fallback_Metadata_When_Fallback_Is_Required_And_Runtime_Contract_Is_Available" - 3/3 passed - 扩展验证已通过: - `dotnet test GFra...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[grammar] ~21-~21: Ensure spelling is correct
Context: ... mapping 判定从逐条线性扫描 IServiceCollection 收敛为单次构建的本地映射索引 - reflection fallback 或重复类型输入场景下,后续 dup...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[grammar] ~31-~31: Ensure spelling is correct
Context: ...ported handler interface 元数据,reflection 注册路径现会复用已筛选且排序好的接口列表 - 同一 handler 类型跨容器重复注册时,不再重复执行 `GetInte...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🔇 Additional comments (2)
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs (1)
401-408: pointer / function pointer 的拒绝路径看起来正确。这里在运行时类型引用入口和可直接引用判定里都统一返回失败,能避免为非法 CQRS 泛型合同继续生成 precise registration,符合本轮修复目标。
Also applies to: 530-532
ai-plan/public/cqrs-rewrite/todos/cqrs-rewrite-migration-tracking.md (1)
10-20: 跟踪文档更新清晰。当前恢复点、已完成的 generator / registrar 收敛项、验证命令和下一步都已集中到 active 文档里,便于后续从 RP-050 恢复。
Also applies to: 33-52, 74-85, 89-91
- 更新 CQRS 重写跟踪中的恢复点与活跃事实,记录 PR #253 已关闭且剩余 thread 为 stale review\n- 调整 CQRS 重写 trace 的下一步,恢复 Phase 8 主线优先级
- 优化 generated registry 激活流程,使用缓存工厂委托优先替代 ConstructorInfo.Invoke\n- 补充私有无参构造 registry 的回归测试,保持生成器产物兼容性\n- 更新 CQRS ai-plan 恢复点与验证记录,指向新的 Phase 8 下一步
- 优化 CqrsHandlerRegistryGenerator 对 pointer 类型的 runtime type 递归重建与发射逻辑 - 修复 function pointer 签名默认直出导致隐藏类型漏回退的判定边界 - 补充 pointer precise registration 与 function pointer fallback 回归测试 - 更新 cqrs-rewrite 跟踪与 trace 到 RP-047
- 优化 CqrsHandlerRegistrar 复用 supported handler interface 缓存 - 补充 registrar 静态缓存隔离与接口缓存复用回归测试 - 更新 cqrs-rewrite 跟踪与 trace 到 RP-048
- 优化 CqrsHandlerRegistrar 使用本地映射索引替代重复线性扫描 - 补充 重复 handler 类型输入仍只注册一份映射的回归测试 - 更新 cqrs-rewrite 跟踪与 trace 到 RP-049
- 修复 CqrsHandlerRegistryGenerator 对 pointer 与 function pointer 的精确注册建模 - 补充生成器测试对输入源 CS0306 与 fallback 诊断的断言 - 更新 cqrs-rewrite 跟踪文档记录 PR #261 review follow-up
- 更新 cqrs-rewrite migration trace,标记 RP-047 已被 RP-050 覆盖并禁止恢复 MakePointerType precise registration - 同步 migration tracking 中 PR #261 的 open thread、CTRF 测试结果与 MegaLinter 状态
2440dbe to
13d52a8
Compare
Summary
Test ResultsDetails
Insights
build-and-test: Run #907
🎉 All tests passed!Slowest Tests
± Comparison with run #905 at a9fd3a8 | 🎉 No failed tests detected across all runs. | 🍂 No flaky tests detected across all runs. | ⏱️ Measured over 9 runs. Github Test Reporter by CTRF 💚 |
Summary by CodeRabbit
Bug Fixes
Refactor
Tests
Documentation