Conversation
- 在 EnumExtensionsGeneratorSnapshotTests.cs 中补充 snapshotFileNameSelector 的 null 分支覆盖,新增默认快照文件名选择器用例及对应快照资产 - 强化 GeneratorSnapshotTest.cs 的快照路径校验,拒绝空白文件名、绝对路径和目录遍历攻击;将辅助器改为通过 Roslyn GeneratorDriver 读取真实生成结果并验证编译,消除仅依赖 TestState.GeneratedSources 导致的空跑风险 - 新增 GeneratorSnapshotTestSecurityTests.cs 安全回归测试,覆盖绝对路径拒绝和目录逃逸防护两个分支 - 将 Priority、Logger、ContextAware 三组生成器测试统一指向仓库内快照目录,并补齐缺失的快照资产以支持现在强制执行的生成验证
- 实现了 CqrsHandlerRegistryGenerator 源代码生成器 - 减少运行时程序集反射扫描成本提高性能 - 支持 IRequestHandler、INotificationHandler 和 IStreamRequestHandler 接口 - 生成静态注册代码避免运行时动态发现处理器 - 实现精确的运行时类型引用解析机制 - 支持跨程序集类型的反射查找功能 - 添加了日志记录和错误处理机制 - 实现了类型安全的依赖注入注册过程
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (1)**/*.cs📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (16)📓 Common learnings📚 Learning: 2026-04-16T11:55:23.932ZApplied to files:
📚 Learning: 2026-04-16T11:55:23.932ZApplied to files:
📚 Learning: 2026-04-16T14:51:18.170ZApplied to files:
📚 Learning: 2026-04-16T11:55:23.932ZApplied to files:
📚 Learning: 2026-04-16T11:55:23.932ZApplied to files:
📚 Learning: 2026-04-16T11:55:23.932ZApplied to files:
📚 Learning: 2026-04-16T11:55:23.932ZApplied to files:
📚 Learning: 2026-04-16T11:55:23.932ZApplied to files:
📚 Learning: 2026-04-16T11:55:23.932ZApplied to files:
📚 Learning: 2026-04-16T11:55:23.931ZApplied to files:
📚 Learning: 2026-04-16T11:55:23.932ZApplied to files:
📚 Learning: 2026-04-16T11:55:23.932ZApplied to files:
📚 Learning: 2026-04-06T12:45:43.921ZApplied to files:
📚 Learning: 2026-04-16T13:25:59.124ZApplied to files:
📚 Learning: 2026-04-16T11:55:23.931ZApplied to files:
🔇 Additional comments (7)
📝 WalkthroughWalkthrough将 CQRS 处理器注册生成器从运行时接口发现改为编译期收集反射回退元数据;在缺失运行时回退属性契约时报告错误并跳过生成;移除运行时反射发现 helper;同时更新生成器模型、测试、快照与快照路径安全校验(≤50 字)。 Changes
Sequence Diagram(s)sequenceDiagram
participant Generator as 源生成器 (CqrsHandlerRegistryGenerator)
participant Roslyn as Roslyn 编译驱动/语义模型
participant Analysis as 候选分析 (HandlerCandidateAnalysis)
participant RuntimeAttr as 运行时回退属性契约 (CqrsReflectionFallbackAttribute)
Generator->>Roslyn: 读取语法与语义,收集处理器候选
Roslyn->>Analysis: 对候选执行分析,生成 ImplementationRegistrationSpec(含可选 ReflectionFallbackHandlerTypeMetadataName)
Analysis-->>Generator: 返回注册规格集合
Generator->>Generator: 聚合集合化的 ReflectionFallbackHandlerTypeMetadataName
alt 无回退元数据
Generator->>Roslyn: 生成精确注册表源码(不含回退属性)
else 存在回退元数据且 RuntimeAttr 可用
Generator->>Roslyn: 生成程序集级 [CqrsReflectionFallbackAttribute(...)] 与注册表源码
else 存在回退元数据但 RuntimeAttr 不可用
Generator->>Generator: 报告 GF_Cqrs_001 错误诊断并跳过源生成
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 8
🧹 Nitpick comments (1)
GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs (1)
38-56: 错误消息语言不一致第 45 行的编译错误消息使用中文,而第 56 行的断言消息使用英文。建议统一使用同一种语言以保持一致性。
♻️ 建议统一为中文或英文
Assert.That( generated, Is.Not.Empty, - $"Generator '{typeof(TGenerator).FullName}' did not produce any sources."); + $"生成器 '{typeof(TGenerator).FullName}' 未产生任何输出。");🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs` around lines 38 - 56, The two assertion messages use different languages—translate and unify them so both are the same language; specifically update the message built in the Assert after updatedCompilation.GetDiagnostics() (the interpolation starting with "编译生成的代码时出现错误") to match the language used in the later Assert for driver.GetRunResult() (or vice versa), ensuring both Assert.That calls (the one checking compilationErrors and the one checking generated) use consistent wording and language.
🤖 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 161-176: The generator currently bails out when any registrations
produce a non-empty ReflectionFallbackHandlerTypeMetadataName but
generationEnvironment.SupportsReflectionFallbackAttribute is false, which
prevents generating code when a reflection fallback is actually required; add a
unit test that constructs registrations with at least one
ReflectionFallbackHandlerTypeMetadataName (use the same setup as where
ReflectionFallbackHandlerTypeMetadataName is set) and asserts that the generator
returns early (no source added) when
generationEnvironment.SupportsReflectionFallbackAttribute is false, and then
either (A) document this defensive behavior in the Execute/GenerateSource
contract (mentioning that GenerateSource/HintName will not be produced if
reflection fallback is required but unsupported) or (B) update the Execute logic
to emit a clear diagnostic/error before returning so callers/tests can detect
the unsupported-required-fallback scenario (referencing
generationEnvironment.SupportsReflectionFallbackAttribute, registrations,
fallbackHandlerTypeMetadataNames, GenerateSource, context.AddSource and
HintName).
In
`@GFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/PriorityGroup/TestApp_HighPrioritySystem.Priority.g.cs`:
- Around line 6-7: The partial type declaration "partial class
HighPrioritySystem : global::GFramework.Core.Abstractions.Bases.IPrioritized" is
missing XML documentation; add a triple-slash XML comment immediately above that
class declaration including at minimum a <summary> describing the class and its
purpose, and include other tags as applicable (e.g., <remarks> for
implementation details or <inheritdoc/> if inheriting docs from an interface) to
satisfy the rule that internal types must have XML comments; update the
generator/template that emits
PriorityGroup/TestApp_HighPrioritySystem.Priority.g.cs so the generated partial
class always includes these documentation comments.
In
`@GFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.cs`:
- Around line 37-42: The public async test method
Snapshot_BasicEnum_IsMethods_DefaultSnapshotFileNameSelector is missing an XML
<returns> tag; update its XML documentation to include a <returns> element that
states the method returns a Task representing the asynchronous test operation
(e.g., "A Task that represents the asynchronous test."). Ensure the <returns>
tag is added alongside the existing <summary> so the public method's
documentation meets the project's XML doc requirements.
In
`@GFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods_DefaultSnapshotFileNameSelector/Status.EnumExtensions.g.cs`:
- Around line 5-15: Add missing XML documentation for the generated public API:
add a <summary> for the generated partial class StatusExtensions and add <param
name="value"> and <returns> tags for each generated method (IsActive,
IsInactive, IsIn) so all public symbols (StatusExtensions, IsActive, IsInactive,
IsIn) comply with the project's XML-doc rule; update the source generator
template that emits these members to produce the class-level <summary> and for
IsIn include a <param name="values"> description and <returns> for all methods,
then regenerate and commit the updated snapshot file to reflect the new
documentation.
In
`@GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomName_Class/MyService.Logger.g.cs`:
- Line 7: 生成的部分类型声明 partial class MyService 缺少类型级别的 XML 文档注释;在代码生成器模板(负责产生
MyService.Logger.g.cs 的生成逻辑)中为内部类型 MyService 添加符合仓库规范的类型注释(例如在 partial class
MyService 声明前增加 /// <summary>...</summary>),确保注释风格与已有字段注释一致并包含必要描述,更新生成快照以反映此更改。
In
`@GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/GenericClass/MyService.Logger.g.cs`:
- Around line 7-8: MyService<T> is an internal partial generic type missing XML
documentation; add a triple-slash XML doc comment above the type declaration for
partial class MyService<T> including at minimum a <summary> describing the class
and a <typeparam name="T"> describing the generic type parameter (and other tags
like <remarks> if applicable) so the internal type complies with the project's
XML documentation guideline.
In
`@GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/InstanceField_Class/MyService.Logger.g.cs`:
- Around line 7-8: The partial class MyService is an internal type without XML
documentation; add a triple-slash XML comment above the declaration for partial
class MyService including at minimum a <summary> describing the class purpose
(and other tags if applicable), so the internal type complies with the rule that
internal types must have XML docs; update the generated file's partial class
MyService declaration to include the appropriate /// <summary>…</summary>
comment.
In
`@GFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs`:
- Around line 18-22: The lazy initialization of _context reads _contextProvider
without synchronization and can race with
SetContextProvider/ResetContextProvider causing a null reference when calling
GetContext(); fix by serializing access to _contextProvider and _context: either
(A) introduce a dedicated lock object (e.g., _contextProviderLock) and wrap the
lazy-init block that sets _contextProvider and assigns _context as well as
SetContextProvider and ResetContextProvider in that lock, or (B) use an atomic
snapshot/CompareExchange pattern (capture var provider = _contextProvider; if
provider is null create a new provider and use Interlocked.CompareExchange to
publish it, then call provider.GetContext() on the non-null snapshot) and ensure
a null-check before calling GetContext(); apply the same pattern to the other
locations (lines 32-43) that access _contextProvider/_context.
---
Nitpick comments:
In `@GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs`:
- Around line 38-56: The two assertion messages use different
languages—translate and unify them so both are the same language; specifically
update the message built in the Assert after updatedCompilation.GetDiagnostics()
(the interpolation starting with "编译生成的代码时出现错误") to match the language used in
the later Assert for driver.GetRunResult() (or vice versa), ensuring both
Assert.That calls (the one checking compilationErrors and the one checking
generated) use consistent wording and language.
🪄 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: d08cea62-c3b1-4094-b7bb-50a9ac00db4e
📒 Files selected for processing (20)
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/BasicPriority/TestApp_MySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/GenericClass/TestApp_GenericSystem_T_.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/NegativePriority/TestApp_CriticalSystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/PriorityGroup/TestApp_HighPrioritySystem.Priority.g.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTestSecurityTests.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods_DefaultSnapshotFileNameSelector/Status.EnumExtensions.g.csGFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomFieldName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/DefaultConfiguration_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/GenericClass/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/InstanceField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/PublicField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Code Quality & Security
- GitHub Check: Analyze (C#)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.cs: All public, protected, and internal types and members in C# MUST include XML documentation comments (///) using<summary>,<param>,<returns>,<exception>, and<remarks>tags where applicable
XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax
If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML documentation
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds and edge cases, and registration order or lifecycle sequencing
Avoid obvious comments such as// increment i
Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling, if any
Comments MUST NOT be trivial, redundant, or misleading. Prefer explainingwhyandwhen, not justwhat
Code should remain understandable without requiring external context. Prefer slightly more explanation over too little for framework code
Missing required documentation is a coding standards violation. Code that does not meet the documentation rules is considered incomplete
Do not rely on implicit imports. Declare every requiredusingexplicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace patternGFramework.{Module}.{Feature}with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, and con...
Files:
GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/GenericClass/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/InstanceField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/BasicPriority/TestApp_MySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/GenericClass/TestApp_GenericSystem_T_.Priority.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/PriorityGroup/TestApp_HighPrioritySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/DefaultConfiguration_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/PublicField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods_DefaultSnapshotFileNameSelector/Status.EnumExtensions.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/NegativePriority/TestApp_CriticalSystem.Priority.g.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTestSecurityTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomFieldName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
🧠 Learnings (22)
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: LoggerGenerator source generator with [Log] attribute must automatically generate log fields and logging helper methods
Applied to files:
GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/GenericClass/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/InstanceField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/DefaultConfiguration_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/PublicField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomFieldName_Class/MyService.Logger.g.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : When generator behavior changes intentionally, update snapshots together with the implementation
Applied to files:
GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/GenericClass/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/InstanceField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/BasicPriority/TestApp_MySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/GenericClass/TestApp_GenericSystem_T_.Priority.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/PriorityGroup/TestApp_HighPrioritySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/DefaultConfiguration_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/PublicField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods_DefaultSnapshotFileNameSelector/Status.EnumExtensions.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/NegativePriority/TestApp_CriticalSystem.Priority.g.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTestSecurityTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomFieldName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.Tests.cs : Preserve snapshot-based verification patterns already used in the repository for source generator tests
Applied to files:
GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/GenericClass/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/InstanceField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/BasicPriority/TestApp_MySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/GenericClass/TestApp_GenericSystem_T_.Priority.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/PriorityGroup/TestApp_HighPrioritySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/DefaultConfiguration_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/PublicField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods_DefaultSnapshotFileNameSelector/Status.EnumExtensions.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/NegativePriority/TestApp_CriticalSystem.Priority.g.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTestSecurityTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomFieldName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.Tests.cs : Source generator changes MUST be covered by generator tests
Applied to files:
GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/GenericClass/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/InstanceField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/BasicPriority/TestApp_MySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/GenericClass/TestApp_GenericSystem_T_.Priority.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/PriorityGroup/TestApp_HighPrioritySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/DefaultConfiguration_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/PublicField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods_DefaultSnapshotFileNameSelector/Status.EnumExtensions.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/NegativePriority/TestApp_CriticalSystem.Priority.g.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTestSecurityTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomFieldName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : Keep source generators deterministic and free of hidden environment or network dependencies
Applied to files:
GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/GenericClass/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/BasicPriority/TestApp_MySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/GenericClass/TestApp_GenericSystem_T_.Priority.g.csGFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/DefaultConfiguration_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTestSecurityTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.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/Logging/snapshots/LoggerGenerator/GenericClass/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/InstanceField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/BasicPriority/TestApp_MySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/GenericClass/TestApp_GenericSystem_T_.Priority.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/PriorityGroup/TestApp_HighPrioritySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/DefaultConfiguration_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/PublicField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods_DefaultSnapshotFileNameSelector/Status.EnumExtensions.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/NegativePriority/TestApp_CriticalSystem.Priority.g.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTestSecurityTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomFieldName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.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/Logging/snapshots/LoggerGenerator/GenericClass/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/InstanceField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/BasicPriority/TestApp_MySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/GenericClass/TestApp_GenericSystem_T_.Priority.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/PriorityGroup/TestApp_HighPrioritySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/DefaultConfiguration_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/PublicField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods_DefaultSnapshotFileNameSelector/Status.EnumExtensions.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/NegativePriority/TestApp_CriticalSystem.Priority.g.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTestSecurityTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomFieldName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: CqrsHandlerRegistryGenerator must generate CQRS handler registries for consuming assemblies with runtime prioritization of generated products and fallback to reflection scanning; non-default assemblies must be explicitly registered via RegisterCqrsHandlersFromAssembly or RegisterCqrsHandlersFromAssemblies
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Public API changes must be covered by unit or integration tests
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/GenericClass/TestApp_GenericSystem_T_.Priority.g.csGFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/PriorityGroup/TestApp_HighPrioritySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods_DefaultSnapshotFileNameSelector/Status.EnumExtensions.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/NegativePriority/TestApp_CriticalSystem.Priority.g.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTestSecurityTests.csGFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTestSecurityTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Keep tests focused on observable behavior, not implementation trivia
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : 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
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : Preserve deterministic behavior in registries, lifecycle orchestration, and generated outputs
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: PriorityGenerator source generator with [Priority] attribute must automatically generate priority comparison implementations
Applied to files:
GFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/BasicPriority/TestApp_MySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/GenericClass/TestApp_GenericSystem_T_.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/PriorityGroup/TestApp_HighPrioritySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/NegativePriority/TestApp_CriticalSystem.Priority.g.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: ContextAwareGenerator source generator with [ContextAware] attribute must automatically implement IContextAware boilerplate logic
Applied to files:
GFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Reuse existing architecture test infrastructure when relevant: `ArchitectureTestsBase<T>`, `SyncTestArchitecture`, `AsyncTestArchitecture`
Applied to files:
GFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Mirror the source structure in test projects whenever practical
Applied to files:
GFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: EnumExtensionsGenerator source generator with [GenerateEnumExtensions] attribute must automatically generate enum extension capabilities
Applied to files:
GFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods_DefaultSnapshotFileNameSelector/Status.EnumExtensions.g.csGFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: Source Generators must target netstandard2.1 and provide incremental Roslyn code generation capabilities
Applied to files:
GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Applied to files:
GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical
Applied to files:
GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTestSecurityTests.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: IContextAware must provide unified context access through SetContext(IArchitectureContext) method for all components
Applied to files:
GFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
🔇 Additional comments (26)
GFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/BasicPriority/TestApp_MySystem.Priority.g.cs (1)
6-6: 与前述问题重复:类型级 XML 文档缺失该快照中的
internal partial class MySystem同样缺少类型/// <summary>,建议通过生成器模板统一修复并批量更新快照。GFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/GenericClass/TestApp_GenericSystem_T_.Priority.g.cs (1)
6-6: 与前述问题重复:类型级 XML 文档缺失
internal partial class GenericSystem<T>仍缺少类型注释,建议在生成器模板层统一补齐。GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/PublicField_Class/MyService.Logger.g.cs (1)
7-7: 与前述问题重复:类型级 XML 文档缺失该
internal partial class MyService依然缺少类型文档注释,建议与其它生成快照一起统一修复。GFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/NegativePriority/TestApp_CriticalSystem.Priority.g.cs (1)
6-6: 与前述问题重复:类型级 XML 文档缺失
internal partial class CriticalSystem缺少/// <summary>,建议通过生成器统一补齐。GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/DefaultConfiguration_Class/MyService.Logger.g.cs (1)
7-7: 与前述问题重复:类型级 XML 文档缺失该快照同样缺少类型级 XML 注释,建议在生成器侧一次性修复并重录快照。
GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomFieldName_Class/MyService.Logger.g.cs (1)
7-7: 与前述问题重复:类型级 XML 文档缺失
internal partial class MyService仍缺少类型文档注释,建议统一由生成模板输出。GFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs (1)
6-6: 与前述问题重复:类型级 XML 文档缺失
internal partial class MyRule缺少类型/// <summary>注释,建议在 ContextAware 生成模板中统一补齐。GFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.cs (1)
87-90: 快照目录解析重构实现清晰且可维护这里把目录定位逻辑收敛到
GetSnapshotFolder(),同时用Path.GetFullPath做归一化,和当前测试基建的路径校验策略是匹配的。Also applies to: 92-107
GFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.cs (1)
53-54: Priority 快照路径重构一致且稳妥各场景统一走
GetSnapshotFolder(string scenarioName)后,可读性和后续维护性都更好。Also applies to: 96-97, 149-150, 192-193, 195-212
GFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.cs (1)
99-100: Logger 快照目录重构实现一致统一的
GetSnapshotFolder让各测试场景的目录定位逻辑更集中,和同 PR 其他快照测试保持了一致。Also applies to: 191-192, 283-284, 375-376, 467-468, 559-560, 562-579
GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs (3)
62-64: 安全增强:路径验证使用
ResolveSnapshotPath替代直接的Path.Combine是很好的安全增强,确保在访问文件系统前验证路径合法性。
95-110: 实现正确:支持经典与增量生成器
CreateGenerator方法通过模式匹配正确处理了ISourceGenerator和IIncrementalGenerator两种类型,并使用AsSourceGenerator()扩展方法进行适配。XML 文档完整,异常消息清晰。
112-141: 安全实现完善
ResolveSnapshotPath方法的路径验证逻辑设计合理:
- 拒绝空白和绝对路径(第 123 行)
- 规范化路径后进行包含关系判断(第 129-130 行)
- 使用平台感知的字符串比较(Windows 不区分大小写)
- 通过
snapshotRoot + Path.DirectorySeparatorChar前缀检查防止前缀攻击(如/rootvs/root2)XML 文档完整,注释说明了规范化的原因。
GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTestSecurityTests.cs (3)
1-12: 测试类结构良好导入声明清晰,命名空间符合规范,XML 文档说明了测试目的。使用常量
EnumAttributeNamespace避免魔法字符串是良好实践。
14-44: 安全测试覆盖充分两个测试方法分别验证了:
- 绝对路径被拒绝(第 18-28 行)
- 路径遍历攻击被拒绝(第 34-44 行)
测试命名遵循
MethodName_Condition_ExpectedResult模式,XML 文档清晰说明测试意图。使用不存在的目录路径确保了异常在文件系统访问之前抛出。
46-91: 辅助方法设计合理
CreateSnapshotRoot通过组合Test.ID和Guid确保测试隔离,避免状态共享BuildSource自包含地定义了触发生成器所需的最小源码,不依赖外部文件- 使用
$$原始字符串字面量语法正确处理了插值GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs (9)
22-24: LGTM!新增的常量
CqrsReflectionFallbackAttributeMetadataName遵循命名规范,与现有的元数据名称常量风格一致。
59-62: LGTM!正确检测
CqrsReflectionFallbackAttribute的可用性,并将结果传递到生成环境中,实现了对不同运行时合约版本的兼容。
132-147: LGTM!当存在无法静态注册的处理器接口时,使用
??=确保只记录一次回退元数据名称。注释清晰地解释了这种保守策略的设计意图。
526-543: LGTM!程序集级别
CqrsReflectionFallbackAttribute的生成逻辑正确:
- 仅在支持该属性且存在回退处理器时才生成
- 使用
EscapeStringLiteral正确转义类型名称中的特殊字符- 生成的字符串字面量语法正确
604-608: LGTM!简化了
AppendReflectionHelpers的调用条件,现在仅在存在外部程序集类型查找时才添加辅助方法,与移除运行时接口发现逻辑保持一致。
1071-1078: LGTM!
ImplementationRegistrationSpec记录结构正确添加了ReflectionFallbackHandlerTypeMetadataName字段,与其他字段命名风格一致。
1114-1127: LGTM!
HandlerCandidateAnalysis的Equals方法正确更新,使用StringComparer.Ordinal比较新增的ReflectionFallbackHandlerTypeMetadataName字段,保持了确定性行为。
1169-1172: LGTM!
GetHashCode方法正确包含新字段,处理 null 值的方式与现有的ReflectionTypeMetadataName字段一致。
1193-1195: LGTM!
GenerationEnvironment记录结构正确添加了SupportsReflectionFallbackAttribute属性。GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs (1)
1004-1012: LGTM!新增的负向断言正确验证了生成器不再输出旧版运行时接口发现逻辑的标记。这些断言与
ExternalAssemblyPreciseLookupExpected的精确匹配验证互补,确保了重构的完整性。Based on learnings: "Source generator changes MUST be covered by generator tests" - 此测试正确覆盖了生成器行为的变更。
- 新增 PriorityGenerator 为标记 Priority 特性的类自动生成 IPrioritized 接口实现 - 新增 EnumExtensionsGenerator 为枚举自动生成 Is 和 IsIn 扩展方法 - 新增 LoggerGenerator 为标记 Log 特性的类自动生成日志字段 - 新增 ContextAwareGenerator 为标记 ContextAware 特性的类自动生成 IContextAware 接口实现 - 新增 CqrsHandlerRegistryGenerator 为 CQRS 处理器生成编译时注册器减少运行时反射开销
There was a problem hiding this comment.
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 (1)
GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs (1)
12-18: 🛠️ Refactor suggestion | 🟠 Major补全
RunAsync的 XML 契约说明。
RunAsync现在不只是“运行快照测试”:它会手动构建 Roslyn 编译、在编译报错时失败、在生成结果为空时失败、首跑时落盘快照并中断测试,还会校验快照路径安全。当前注释没有把这些前置条件和失败语义说明清楚,调用方很难从 API 文档理解这个测试基类的真实约束。 As per coding guidelines, "Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling" and "Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs` around lines 12 - 18, 补充 GeneratorSnapshotTest.RunAsync 的 XML 文档以明确方法行为:在 RunAsync 的 <summary> 和 <param> 注释中说明它不只是“运行快照测试”,而是会手动构建 Roslyn 编译并在存在编译错误时抛出/使测试失败(列出可能抛出的异常或诊断聚合),说明当生成器未产出任何结果时会失败,以及首次运行时会将生成结果写入磁盘并中断测试以便手动审查;在 <param> 对 source、snapshotFolder 和 snapshotFileNameSelector 的注释中说明 snapshotFileNameSelector 为空时使用原始生成文件名;在 <returns> 中标注返回 Task 并说明何时完成或失败;并补充边界情况与安全检查(例如对 snapshotFolder 的路径安全校验、文件写入失败的处理、生成器诊断/警告处理策略)以便调用方理解核心决策与失败语义(参照类名 GeneratorSnapshotTest 和方法名 RunAsync 以定位修改位置)。
♻️ Duplicate comments (1)
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs (1)
168-173:⚠️ Potential issue | 🟠 Major不要在这里静默放弃整个注册器生成。
这里直接
return后,消费方只会看到CqrsHandlerRegistry.g.cs消失,却看不到是“存在 fallback 需求但 runtime 缺少CqrsReflectionFallbackAttribute”导致的。这个分支是有意的防御逻辑,但最好在返回前发一个明确 diagnostic,并带上触发的 fallback handler metadata name,否则定位成本会很高。 As per coding guidelines: "Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior".🤖 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 168 - 173, Before returning from the CanEmitGeneratedRegistry check, emit a diagnostic that explains why registry generation is being skipped: create a Diagnostic (via the generator’s context.ReportDiagnostic) with a clear message stating that generation is skipped due to missing CqrsReflectionFallbackAttribute support at runtime and include the entries from fallbackHandlerTypeMetadataNames so callers know which handlers triggered the fallback requirement; then return as before. Target the code around CanEmitGeneratedRegistry, generationEnvironment.SupportsReflectionFallbackAttribute, fallbackHandlerTypeMetadataNames and ensure the diagnostic references the CqrsHandlerRegistry.g.cs generation being omitted.
🧹 Nitpick comments (2)
GFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.cs (1)
204-210: 建议在IsIn文档里明确values == null的契约。实现已在 Line 214 定义了
values为null时返回false,但当前 XML 注释未显式写出该边界行为,调用方不易从文档直接获知。✏️ 建议修改(文档层)
- builder.AppendLine(" /// <param name=\"values\">用于匹配的候选枚举值集合。</param>"); + builder.AppendLine(" /// <param name=\"values\">用于匹配的候选枚举值集合;当为 <see langword=\"null\" /> 时返回 <see langword=\"false\" />。</param>");As per coding guidelines: XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@GFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.cs` around lines 204 - 210, Update the XML documentation for the IsIn method to specify the contract when the values parameter is null: state explicitly that if values == null the method returns false, describe that this is intentional boundary behavior, and clarify expected usage for callers (e.g., pass an empty array for no matches). Ensure the <param name="values"> and the <returns> summary mention the null-handling behavior so callers can rely on the contract when calling IsIn.GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs (1)
99-101: 补全生成类型的 XML 契约说明。这段
<summary>目前只说明“会补充上下文访问实现”,但没有交代关键语义:默认回退到GameContextProvider、provider 是按类型静态共享、以及SetContextProvider/ResetContextProvider的线程与生命周期约束。对框架级生成代码来说,这些都属于调用方需要知道的契约。As per coding guidelines "Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior" and "If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML documentation".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs` around lines 99 - 101, Update the generated XML <summary> produced by ContextAwareGenerator (the sb.AppendLine calls that emit the type-level documentation) to fully describe the contract: state that the generator emits a context-access implementation that falls back to GameContextProvider when no custom provider is set, that the provider is stored as a static-per-generated-type shared instance, and that SetContextProvider and ResetContextProvider are the registration APIs with their threading and lifecycle constraints (e.g., callers must ensure thread-safety when swapping providers and providers are expected to live for the duration needed by consumers unless explicitly reset). Also mention any diagnostics/fallback behavior the generator emits when no provider is available and note the semantic assumption that consumer code may rely on the static per-type provider for cross-instance context access.
🤖 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.SourceGenerators/Rule/ContextAwareGenerator.cs`:
- Around line 143-155: SetContext currently assigns _context without
synchronization while the getter uses lock(_contextSync) to lazily initialize
_context; wrap the assignment in SetContext in the same lock(_contextSync) block
so writes and reads use the same synchronization protocol (i.e., inside
SetContext lock(_contextSync) { _context = context; } and adjust any related
_contextProvider updates under the same lock to avoid races).
- Around line 167-181: The XML docs for SetContextProvider() and
ResetContextProvider() are missing cache/semantics notes: add <remarks> to both
methods explaining that the Context property uses lazy caching via the _context
field (assigned with _context ??= _contextProvider.GetContext()), so calling
SetContextProvider() or ResetContextProvider() does not clear already-cached
_context on existing instances and only affects new or not-yet-initialized
instances; also note that to change/clear an already-cached context one must
call IContextAware.SetContext() on the instance.
In `@GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs`:
- Around line 33-45: The test discards the generator diagnostics by using out _
on RunGeneratorsAndUpdateCompilation; capture the third out parameter (e.g., var
generatorDiagnostics) instead, then inspect it for any DiagnosticSeverity.Error
or other severities you care about and fail the test if non-empty; update the
assertion logic around updatedCompilation/GetDiagnostics (compilationErrors) to
also include generatorDiagnostics in the failure message (or assert
generatorDiagnostics is empty) so generator-reported errors from
RunGeneratorsAndUpdateCompilation are not silently ignored.
In `@GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs`:
- Around line 1179-1194: The test currently calls the private helper
CanEmitGeneratedRegistry via reflection which pins implementation details;
replace this with an observable-behavior test that runs the
CqrsHandlerRegistryGenerator (invoke its Execute path) and asserts on generated
output/diagnostics: when metadata requires fallback but runtime types lack
CqrsReflectionFallbackAttribute, assert that CqrsHandlerRegistry.g.cs is not
produced or a specific diagnostic is emitted. Update the test to feed
appropriate compilation inputs (types/attributes) to the generator, run the
generator, and assert on GeneratedSources and Diagnostics instead of calling
CanEmitGeneratedRegistry by name.
---
Outside diff comments:
In `@GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs`:
- Around line 12-18: 补充 GeneratorSnapshotTest.RunAsync 的 XML 文档以明确方法行为:在
RunAsync 的 <summary> 和 <param> 注释中说明它不只是“运行快照测试”,而是会手动构建 Roslyn
编译并在存在编译错误时抛出/使测试失败(列出可能抛出的异常或诊断聚合),说明当生成器未产出任何结果时会失败,以及首次运行时会将生成结果写入磁盘并中断测试以便手动审查;在
<param> 对 source、snapshotFolder 和 snapshotFileNameSelector 的注释中说明
snapshotFileNameSelector 为空时使用原始生成文件名;在 <returns> 中标注返回 Task
并说明何时完成或失败;并补充边界情况与安全检查(例如对 snapshotFolder
的路径安全校验、文件写入失败的处理、生成器诊断/警告处理策略)以便调用方理解核心决策与失败语义(参照类名 GeneratorSnapshotTest 和方法名
RunAsync 以定位修改位置)。
---
Duplicate comments:
In `@GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs`:
- Around line 168-173: Before returning from the CanEmitGeneratedRegistry check,
emit a diagnostic that explains why registry generation is being skipped: create
a Diagnostic (via the generator’s context.ReportDiagnostic) with a clear message
stating that generation is skipped due to missing
CqrsReflectionFallbackAttribute support at runtime and include the entries from
fallbackHandlerTypeMetadataNames so callers know which handlers triggered the
fallback requirement; then return as before. Target the code around
CanEmitGeneratedRegistry,
generationEnvironment.SupportsReflectionFallbackAttribute,
fallbackHandlerTypeMetadataNames and ensure the diagnostic references the
CqrsHandlerRegistry.g.cs generation being omitted.
---
Nitpick comments:
In `@GFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.cs`:
- Around line 204-210: Update the XML documentation for the IsIn method to
specify the contract when the values parameter is null: state explicitly that if
values == null the method returns false, describe that this is intentional
boundary behavior, and clarify expected usage for callers (e.g., pass an empty
array for no matches). Ensure the <param name="values"> and the <returns>
summary mention the null-handling behavior so callers can rely on the contract
when calling IsIn.
In `@GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs`:
- Around line 99-101: Update the generated XML <summary> produced by
ContextAwareGenerator (the sb.AppendLine calls that emit the type-level
documentation) to fully describe the contract: state that the generator emits a
context-access implementation that falls back to GameContextProvider when no
custom provider is set, that the provider is stored as a
static-per-generated-type shared instance, and that SetContextProvider and
ResetContextProvider are the registration APIs with their threading and
lifecycle constraints (e.g., callers must ensure thread-safety when swapping
providers and providers are expected to live for the duration needed by
consumers unless explicitly reset). Also mention any diagnostics/fallback
behavior the generator emits when no provider is available and note the semantic
assumption that consumer code may rely on the static per-type provider for
cross-instance context access.
🪄 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: 2558a26c-7b40-48a3-95da-257073073cd1
📒 Files selected for processing (26)
GFramework.Core.SourceGenerators/Bases/PriorityGenerator.csGFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.csGFramework.Core.SourceGenerators/Logging/LoggerGenerator.csGFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/BasicPriority/TestApp_MySystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/GenericClass/TestApp_GenericSystem_T_.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/NegativePriority/TestApp_CriticalSystem.Priority.g.csGFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/PriorityGroup/TestApp_HighPrioritySystem.Priority.g.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.csGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsInMethod/Status.EnumExtensions.g.txtGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods/Status.EnumExtensions.g.txtGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods_DefaultSnapshotFileNameSelector/Status.EnumExtensions.g.csGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/DisableAllGeneratedMethods/Status.EnumExtensions.g.txtGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/DisableIsInMethod/Status.EnumExtensions.g.txtGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/DisableIsMethods/Status.EnumExtensions.g.txtGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/EnumWithFlagValues/Permissions.EnumExtensions.g.txtGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomFieldName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomName_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/DefaultConfiguration_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/GenericClass/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/InstanceField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/PublicField_Class/MyService.Logger.g.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
✅ Files skipped from review due to trivial changes (16)
- GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/GenericClass/MyService.Logger.g.cs
- GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomName_Class/MyService.Logger.g.cs
- GFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/DisableAllGeneratedMethods/Status.EnumExtensions.g.txt
- GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/DefaultConfiguration_Class/MyService.Logger.g.cs
- GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/PublicField_Class/MyService.Logger.g.cs
- GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/CustomFieldName_Class/MyService.Logger.g.cs
- GFramework.SourceGenerators.Tests/Logging/snapshots/LoggerGenerator/InstanceField_Class/MyService.Logger.g.cs
- GFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/PriorityGroup/TestApp_HighPrioritySystem.Priority.g.cs
- GFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/DisableIsMethods/Status.EnumExtensions.g.txt
- GFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/DisableIsInMethod/Status.EnumExtensions.g.txt
- GFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/BasicPriority/TestApp_MySystem.Priority.g.cs
- GFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods/Status.EnumExtensions.g.txt
- GFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods_DefaultSnapshotFileNameSelector/Status.EnumExtensions.g.cs
- GFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsInMethod/Status.EnumExtensions.g.txt
- GFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/EnumWithFlagValues/Permissions.EnumExtensions.g.txt
- GFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/NegativePriority/TestApp_CriticalSystem.Priority.g.cs
🚧 Files skipped from review as they are similar to previous changes (3)
- GFramework.SourceGenerators.Tests/Bases/snapshots/PriorityGenerator/GenericClass/TestApp_GenericSystem_T_.Priority.g.cs
- GFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.cs
- GFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Analyze (C#)
- GitHub Check: Code Quality & Security
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.cs: All public, protected, and internal types and members in C# MUST include XML documentation comments (///) using<summary>,<param>,<returns>,<exception>, and<remarks>tags where applicable
XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax
If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML documentation
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds and edge cases, and registration order or lifecycle sequencing
Avoid obvious comments such as// increment i
Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling, if any
Comments MUST NOT be trivial, redundant, or misleading. Prefer explainingwhyandwhen, not justwhat
Code should remain understandable without requiring external context. Prefer slightly more explanation over too little for framework code
Missing required documentation is a coding standards violation. Code that does not meet the documentation rules is considered incomplete
Do not rely on implicit imports. Declare every requiredusingexplicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace patternGFramework.{Module}.{Feature}with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, and con...
Files:
GFramework.Core.SourceGenerators/Bases/PriorityGenerator.csGFramework.Core.SourceGenerators/Logging/LoggerGenerator.csGFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
🧠 Learnings (27)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: CqrsHandlerRegistryGenerator must generate CQRS handler registries for consuming assemblies with runtime prioritization of generated products and fallback to reflection scanning; non-default assemblies must be explicitly registered via RegisterCqrsHandlersFromAssembly or RegisterCqrsHandlersFromAssemblies
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: PriorityGenerator source generator with [Priority] attribute must automatically generate priority comparison implementations
Applied to files:
GFramework.Core.SourceGenerators/Bases/PriorityGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : When generator behavior changes intentionally, update snapshots together with the implementation
Applied to files:
GFramework.Core.SourceGenerators/Bases/PriorityGenerator.csGFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : Any change to public API, lifecycle semantics, module behavior, or extension points MUST update the related XML docs
Applied to files:
GFramework.Core.SourceGenerators/Bases/PriorityGenerator.csGFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.csGFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.Tests.cs : Source generator changes MUST be covered by generator tests
Applied to files:
GFramework.Core.SourceGenerators/Bases/PriorityGenerator.csGFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : All public, protected, and internal types and members in C# MUST include XML documentation comments (`///`) using `<summary>`, `<param>`, `<returns>`, `<exception>`, and `<remarks>` tags where applicable
Applied to files:
GFramework.Core.SourceGenerators/Bases/PriorityGenerator.csGFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML documentation
Applied to files:
GFramework.Core.SourceGenerators/Bases/PriorityGenerator.csGFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : Keep source generators deterministic and free of hidden environment or network dependencies
Applied to files:
GFramework.Core.SourceGenerators/Bases/PriorityGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Applied to files:
GFramework.Core.SourceGenerators/Bases/PriorityGenerator.csGFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.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.SourceGenerators/Bases/PriorityGenerator.csGFramework.Core.SourceGenerators/Logging/LoggerGenerator.csGFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: LoggerGenerator source generator with [Log] attribute must automatically generate log fields and logging helper methods
Applied to files:
GFramework.Core.SourceGenerators/Logging/LoggerGenerator.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: EnumExtensionsGenerator source generator with [GenerateEnumExtensions] attribute must automatically generate enum extension capabilities
Applied to files:
GFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: CqrsHandlerRegistryGenerator must generate CQRS handler registries for consuming assemblies with runtime prioritization of generated products and fallback to reflection scanning; non-default assemblies must be explicitly registered via RegisterCqrsHandlersFromAssembly or RegisterCqrsHandlersFromAssemblies
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.Tests.cs : Preserve snapshot-based verification patterns already used in the repository for source generator tests
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Public API changes must be covered by unit or integration tests
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : 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
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : Preserve deterministic behavior in registries, lifecycle orchestration, and generated outputs
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Keep tests focused on observable behavior, not implementation trivia
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.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.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: ContextAwareGenerator source generator with [ContextAware] attribute must automatically implement IContextAware boilerplate logic
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : 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.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: IContextAware must provide unified context access through SetContext(IArchitectureContext) method for all components
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: Source Generators must target netstandard2.1 and provide incremental Roslyn code generation capabilities
Applied to files:
GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Reuse existing architecture test infrastructure when relevant: `ArchitectureTestsBase<T>`, `SyncTestArchitecture`, `AsyncTestArchitecture`
Applied to files:
GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Mirror the source structure in test projects whenever practical
Applied to files:
GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs
🔇 Additional comments (5)
GFramework.Core.SourceGenerators/Logging/LoggerGenerator.cs (2)
74-77: 这段生成类型注释补充得很好。为生成的
partial类型添加<summary>能清晰表达职责,提升生成代码可读性与可维护性。As per coding guidelines: "All public, protected, and internal types and members in C# MUST include XML documentation comments (
///) using<summary>,<param>,<returns>,<exception>, and<remarks>tags where applicable".
83-85: 日志字段的 XML 注释完善且准确。字段级
<summary>明确了该成员是自动生成产物,便于使用方快速识别来源。As per coding guidelines: "Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior".
GFramework.Core.SourceGenerators/Bases/PriorityGenerator.cs (1)
121-123: 类级 XML 注释补充到位,方向正确。新增的
<summary>能清晰表达该生成分部类型的职责,与本次生成行为一致,建议保留。GFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.cs (2)
98-100: 生成的扩展类文档补充到位。这里新增的类级
<summary>能明确生成对象与目标枚举类型,提升了生成代码可读性与 IDE 提示质量。As per coding guidelines: Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior.
182-188:Is{Member}扩展方法文档结构完整,方向正确。补齐
<summary> + <param> + <returns>,并通过cref指向具体枚举成员,契约表达比之前清晰。As per coding guidelines: All public, protected, and internal types and members in C# MUST include XML documentation comments (
///) using<summary>,<param>,<returns>,<exception>, and<remarks>tags where applicable.
- 实现了CqrsHandlerRegistryGenerator用于自动生成CQRS处理器注册器 - 添加了EnumExtensionsGenerator用于自动生成枚举相关的扩展方法 - 创建了ContextAwareGenerator为标记类自动生成IContextAware接口实现 - 支持运行时类型引用的安全编码和反射回退机制 - 实现了精确的运行时类型引用描述和泛型类型处理 - 添加了完整的诊断报告和错误处理机制
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs (2)
137-176: 建议文档补充与ContextAwareBase的行为差异说明。生成的实现使用
_contextSync进行同步,而ContextAwareBase(手动继承基类)的SetContext/GetContext没有锁保护。两种实现路径的线程安全保证不同:
- ContextAwareBase:简单属性赋值,无同步
- 生成代码:支持静态提供者的惰性初始化,有锁保护
建议在生成代码的类级文档或框架文档中说明这一差异,帮助开发者根据场景选择合适的实现方式。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs` around lines 137 - 176, The generated Context property (created by GenerateContextProperty) uses a lock on _contextSync for lazy initialization of the static _contextProvider and caching _context, which differs from the manual ContextAwareBase implementation whose SetContext/GetContext are not synchronized; update the XML/class-level doc comments emitted by GenerateContextProperty (or add a remark block near the protected Context property) to explicitly state this behavioral and thread-safety difference versus ContextAwareBase and give guidance when to prefer each approach (mentioning SetContext/GetContext and _contextSync/_contextProvider to locate the relevant code).
161-174: 在锁内调用_contextProvider.GetContext()存在潜在的锁嵌套风险。
GetContext()被锁保护(Line 172),但根据GameContextProvider的实现,其内部会调用GameContext.GetFirstArchitectureContext(),后者访问ArchitectureDictionary。如果GameContext内部也使用了同步机制,可能会形成锁嵌套,在高并发场景下增加死锁风险或性能瓶颈。建议在文档或内联注释中明确
IArchitectureContextProvider.GetContext()的线程安全契约,确保实现者了解该方法会在持有_contextSync锁的情况下被调用。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs` around lines 161 - 174, The code calls _contextProvider.GetContext() while holding _contextSync which can cause nested-lock/deadlock if implementations (e.g., GameContextProvider -> GameContext.GetFirstArchitectureContext()) use their own synchronization; update the codebase by (1) adding a clear thread-safety contract to IArchitectureContextProvider.GetContext() XML docs stating that implementations must be safe to be called while _contextSync is held or must be non-blocking, (2) add an inline comment above the lock in ContextAwareGenerator (referencing _contextSync, _contextProvider.GetContext(), and _context) documenting this contract and warning implementers, and (3) optionally consider refactoring to initialize _contextProvider under _contextSync but call GetContext() outside the lock if implementations cannot be guaranteed non-blocking (adjust logic around _contextProvider ??= and _context ??= 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 `@GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs`:
- Around line 561-565: 为 GenerateSource 方法补充完整的契约级 XML 文档,说明该方法生成的源码类型(registry
类/方法/属性等)、生成时机与目的(包括何时会产出程序集级 CqrsReflectionFallbackAttribute
与何时完全跳过产出)、对输入参数的语义假设(GenerationEnvironment、registrations、fallbackHandlerTypeMetadataNames
各自代表什么、fallback
列表如何被使用)、诊断边界(哪些错误会以编译器诊断报告、哪些会作为回退行为记录)以及任何不变条件或线程/性能假设;在文档中引用方法名
GenerateSource 和参数名
GenerationEnvironment、registrations、fallbackHandlerTypeMetadataNames 以便定位。
In `@GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs`:
- Around line 1171-1262: Add a positive test that covers the branch where the
runtime contract includes the CqrsReflectionFallbackAttribute so the generator
emits CqrsHandlerRegistry.g.cs with assembly-level fallback metadata;
specifically, create a new test (parallel to
Reports_Diagnostic_And_Skips_Registry_When_Fallback_Metadata_Is_Required_But_Runtime_Contract_Lacks_Fallback_Attribute)
that supplies a source containing a definition of
GFramework.Cqrs.CqrsReflectionFallbackAttribute at runtime, invokes
ExecuteGenerator, then asserts that no GF_Cqrs_001 error is reported and that
execution.GeneratedSources contains the generated CqrsHandlerRegistry.g.cs and
that its contents reference the assembly-level fallback metadata and the handler
type (e.g., TestApp.Container+HiddenHandler).
- Line 1244: The test call to ExecuteGenerator in
Generates_Registry_For_Hidden_Handler_When_Fallback_Marker_Is_Unavailable must
allow unsafe code; add an optional parameter allowUnsafe = false to
ExecuteGenerator, thread that flag into the compilation/parse options creation
inside ExecuteGenerator so the C# compilation is created with AllowUnsafe = true
when requested, and then change the call at the test (the var execution =
ExecuteGenerator(source);) to var execution = ExecuteGenerator(source,
allowUnsafe: true);; reference ExecuteGenerator and the test
Generates_Registry_For_Hidden_Handler_When_Fallback_Marker_Is_Unavailable so you
change only the generator helper signature and its use in that test.
---
Nitpick comments:
In `@GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs`:
- Around line 137-176: The generated Context property (created by
GenerateContextProperty) uses a lock on _contextSync for lazy initialization of
the static _contextProvider and caching _context, which differs from the manual
ContextAwareBase implementation whose SetContext/GetContext are not
synchronized; update the XML/class-level doc comments emitted by
GenerateContextProperty (or add a remark block near the protected Context
property) to explicitly state this behavioral and thread-safety difference
versus ContextAwareBase and give guidance when to prefer each approach
(mentioning SetContext/GetContext and _contextSync/_contextProvider to locate
the relevant code).
- Around line 161-174: The code calls _contextProvider.GetContext() while
holding _contextSync which can cause nested-lock/deadlock if implementations
(e.g., GameContextProvider -> GameContext.GetFirstArchitectureContext()) use
their own synchronization; update the codebase by (1) adding a clear
thread-safety contract to IArchitectureContextProvider.GetContext() XML docs
stating that implementations must be safe to be called while _contextSync is
held or must be non-blocking, (2) add an inline comment above the lock in
ContextAwareGenerator (referencing _contextSync, _contextProvider.GetContext(),
and _context) documenting this contract and warning implementers, and (3)
optionally consider refactoring to initialize _contextProvider under
_contextSync but call GetContext() outside the lock if implementations cannot be
guaranteed non-blocking (adjust logic around _contextProvider ??= and _context
??= 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: 840347f7-f6db-4ba5-9b9d-6d4753f44cbb
📒 Files selected for processing (13)
GFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.csGFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.Cqrs.SourceGenerators/AnalyzerReleases.Shipped.mdGFramework.Cqrs.SourceGenerators/AnalyzerReleases.Unshipped.mdGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsInMethod/Status.EnumExtensions.g.txtGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods/Status.EnumExtensions.g.txtGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods_DefaultSnapshotFileNameSelector/Status.EnumExtensions.g.csGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/DisableIsMethods/Status.EnumExtensions.g.txtGFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/EnumWithFlagValues/Permissions.EnumExtensions.g.txtGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
✅ Files skipped from review due to trivial changes (7)
- GFramework.Cqrs.SourceGenerators/AnalyzerReleases.Shipped.md
- GFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods/Status.EnumExtensions.g.txt
- GFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsInMethod/Status.EnumExtensions.g.txt
- GFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/EnumWithFlagValues/Permissions.EnumExtensions.g.txt
- GFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/BasicEnum_IsMethods_DefaultSnapshotFileNameSelector/Status.EnumExtensions.g.cs
- GFramework.SourceGenerators.Tests/Enums/snapshots/EnumExtensionsGenerator/DisableIsMethods/Status.EnumExtensions.g.txt
- GFramework.Core.SourceGenerators/Enums/EnumExtensionsGenerator.cs
🚧 Files skipped from review as they are similar to previous changes (1)
- GFramework.SourceGenerators.Tests/Core/GeneratorSnapshotTest.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Code Quality & Security
- GitHub Check: Analyze (C#)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.cs: All public, protected, and internal types and members in C# MUST include XML documentation comments (///) using<summary>,<param>,<returns>,<exception>, and<remarks>tags where applicable
XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax
If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML documentation
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds and edge cases, and registration order or lifecycle sequencing
Avoid obvious comments such as// increment i
Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling, if any
Comments MUST NOT be trivial, redundant, or misleading. Prefer explainingwhyandwhen, not justwhat
Code should remain understandable without requiring external context. Prefer slightly more explanation over too little for framework code
Missing required documentation is a coding standards violation. Code that does not meet the documentation rules is considered incomplete
Do not rely on implicit imports. Declare every requiredusingexplicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace patternGFramework.{Module}.{Feature}with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, and con...
Files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
🧠 Learnings (24)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: CqrsHandlerRegistryGenerator must generate CQRS handler registries for consuming assemblies with runtime prioritization of generated products and fallback to reflection scanning; non-default assemblies must be explicitly registered via RegisterCqrsHandlersFromAssembly or RegisterCqrsHandlersFromAssemblies
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: ContextAwareGenerator source generator with [ContextAware] attribute must automatically implement IContextAware boilerplate logic
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : When generator behavior changes intentionally, update snapshots together with the implementation
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.csGFramework.Cqrs.SourceGenerators/AnalyzerReleases.Unshipped.md
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : Keep source generators deterministic and free of hidden environment or network dependencies
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : When adding caching, pooling, or shared mutable state, document thread-safety assumptions and failure modes
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: IContextAware must provide unified context access through SetContext(IArchitectureContext) method for all components
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML documentation
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : Any change to public API, lifecycle semantics, module behavior, or extension points MUST update the related XML docs
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : Code should remain understandable without requiring external context. Prefer slightly more explanation over too little for framework code
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : 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.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.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.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: CqrsHandlerRegistryGenerator must generate CQRS handler registries for consuming assemblies with runtime prioritization of generated products and fallback to reflection scanning; non-default assemblies must be explicitly registered via RegisterCqrsHandlersFromAssembly or RegisterCqrsHandlersFromAssemblies
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.Tests.cs : Source generator changes MUST be covered by generator tests
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : Preserve deterministic behavior in registries, lifecycle orchestration, and generated outputs
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.Tests.cs : Preserve snapshot-based verification patterns already used in the repository for source generator tests
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Public API changes must be covered by unit or integration tests
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Keep tests focused on observable behavior, not implementation trivia
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : 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
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.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.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: IArchitectureContext and Provider types must propagate context capabilities between components enabling unified service access without direct implementation coupling
Applied to files:
GFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : The repository uses `Meziantou.Analyzer`; treat analyzer feedback as part of the coding standard
Applied to files:
GFramework.Cqrs.SourceGenerators/AnalyzerReleases.Unshipped.md
🪛 LanguageTool
GFramework.Cqrs.SourceGenerators/AnalyzerReleases.Unshipped.md
[grammar] ~8-~8: Ensure spelling is correct
Context: ...------------- GF_Cqrs_001 | GFramework.Cqrs.SourceGenerators | Error | CqrsHandl...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🔇 Additional comments (5)
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs (4)
99-109: 类级 XML 文档清晰完整。文档准确解释了生成代码的行为:实例级缓存、默认回退到
GameContextProvider、静态提供者共享语义以及缓存失效的限制。符合编码规范中对生成器管道文档的要求。
178-195:SetContextProvider同步逻辑与文档完整。方法使用与
Contextgetter 相同的锁,XML 备注清晰说明了缓存语义和使用限制。符合之前评审意见的修复要求。
197-212:ResetContextProvider实现正确。锁保护和文档说明到位,适用于测试清理场景。
278-286:SetContext方法体正确添加了锁保护。与
Contextgetter 共享相同的同步协议,避免了显式注入与并发懒加载之间的竞态条件。GFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs (1)
1-96: 快照文件与生成器输出一致。快照正确反映了生成器的最新更改:
- 添加了
_contextSync静态锁对象(Line 18)Context属性使用双重检查锁定模式(Lines 31-46)SetContextProvider、ResetContextProvider和SetContext均使用相同的锁保护- XML 文档完整描述了缓存语义和线程安全行为
之前评审中指出的并发竞态问题已修复。
- 实现了 PascalCase 命名规则检查功能 - 集成了 Git 文件遍历和 grep 文本匹配 - 支持排除特定目录如 Godot 模板和测试快照 - 验证命名空间和目录路径的大小写规范 - 提供详细的违规信息报告和错误定位 - 包含字母数字字符和缩写命名规则校验
- 新增 ContextAwareBase 抽象类提供手动继承的上下文感知基础实现 - 实现 IContextAware 接口的简单实例字段缓存上下文功能 - 添加 ContextAwareGenerator 源代码生成器自动生成上下文感知实现 - 生成器支持 partial 类的 ContextAware 特性标记自动实现 - 提供 CqrsHandlerRegistryGenerator 生成 CQRS 处理器注册器减少运行时反射扫描
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs (1)
158-189: 🛠️ Refactor suggestion | 🟠 Major请给
Execute补上契约级文档。这里已经集中承载了 fallback 元数据聚合、
GF_Cqrs_001诊断以及“何时直接跳过AddSource”的核心语义,但方法本身没有把这些约束说清楚,后续维护只能倒推实现。As per coding guidelines "Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior".
🤖 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 158 - 189, Add a contract-level XML doc comment to the Execute method that explains its responsibilities and semantic assumptions: state that Execute is the gatekeeper for generation (it returns immediately when generationEnvironment.GenerationEnabled is false or when CollectRegistrations yields no registrations), describe that it aggregates fallback handler metadata into fallbackHandlerTypeMetadataNames (via CollectRegistrations) and that generation requires SupportsReflectionFallbackAttribute support and at least one fallback metadata entry (checked by CanEmitGeneratedRegistry) otherwise it reports the GF_Cqrs_001-style diagnostic using ReportMissingReflectionFallbackContractDiagnostic; also document that when checks pass it emits the generated registry source with context.AddSource using GenerateSource(registration, fallbackHandlerTypeMetadataNames), and note any invariants callers can rely on (e.g., registrations non-empty, fallbackHandlerTypeMetadataNames distinct/non-whitespace) and side effects (diagnostic emission, AddSource). Include references to the symbols Execute, generationEnvironment.GenerationEnabled, CollectRegistrations, fallbackHandlerTypeMetadataNames, CanEmitGeneratedRegistry, ReportMissingReflectionFallbackContractDiagnostic, registrations, GenerateSource, and context.AddSource in the comment.
🤖 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.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs`:
- Around line 1244-1263: The tests call ExecuteGenerator and assert on
GeneratorDiagnostics/GeneratedSources but don't assert that
execution.CompilationDiagnostics is empty, so a non-compilable generated result
can wrongly pass; update the test(s) (the block that creates var execution =
ExecuteGenerator(...), var generatorErrors = ..., and missingContractDiagnostic)
to also Assert that execution.CompilationDiagnostics is empty (or contains no
errors) before asserting generator diagnostics and generated sources, ensuring
compilation errors fail the test; apply the same change to the other similar
test block around the ExecuteGenerator call at the referenced second location.
---
Outside diff comments:
In `@GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs`:
- Around line 158-189: Add a contract-level XML doc comment to the Execute
method that explains its responsibilities and semantic assumptions: state that
Execute is the gatekeeper for generation (it returns immediately when
generationEnvironment.GenerationEnabled is false or when CollectRegistrations
yields no registrations), describe that it aggregates fallback handler metadata
into fallbackHandlerTypeMetadataNames (via CollectRegistrations) and that
generation requires SupportsReflectionFallbackAttribute support and at least one
fallback metadata entry (checked by CanEmitGeneratedRegistry) otherwise it
reports the GF_Cqrs_001-style diagnostic using
ReportMissingReflectionFallbackContractDiagnostic; also document that when
checks pass it emits the generated registry source with context.AddSource using
GenerateSource(registration, fallbackHandlerTypeMetadataNames), and note any
invariants callers can rely on (e.g., registrations non-empty,
fallbackHandlerTypeMetadataNames distinct/non-whitespace) and side effects
(diagnostic emission, AddSource). Include references to the symbols Execute,
generationEnvironment.GenerationEnabled, CollectRegistrations,
fallbackHandlerTypeMetadataNames, CanEmitGeneratedRegistry,
ReportMissingReflectionFallbackContractDiagnostic, registrations,
GenerateSource, and context.AddSource in the comment.
🪄 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: 0103721c-7fad-484d-959f-1ef3e8b0ff15
📒 Files selected for processing (5)
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.Core/Rule/ContextAwareBase.csGFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
✅ Files skipped from review due to trivial changes (1)
- GFramework.Core/Rule/ContextAwareBase.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Build and Test
- GitHub Check: Code Quality & Security
- GitHub Check: Analyze (C#)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.cs: All public, protected, and internal types and members in C# MUST include XML documentation comments (///) using<summary>,<param>,<returns>,<exception>, and<remarks>tags where applicable
XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax
If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML documentation
Add inline comments for non-trivial logic, concurrency or threading behavior, performance-sensitive paths, workarounds and edge cases, and registration order or lifecycle sequencing
Avoid obvious comments such as// increment i
Core framework components such as Architecture, Module, System, Context, Registry, Service Module, and Lifecycle types MUST include high-level explanations of responsibilities, lifecycle, interaction with other components, why the abstraction exists, and when to use it instead of alternatives
Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Methods with non-trivial logic MUST document the core idea, key decisions, and edge case handling, if any
Comments MUST NOT be trivial, redundant, or misleading. Prefer explainingwhyandwhen, not justwhat
Code should remain understandable without requiring external context. Prefer slightly more explanation over too little for framework code
Missing required documentation is a coding standards violation. Code that does not meet the documentation rules is considered incomplete
Do not rely on implicit imports. Declare every requiredusingexplicitly in C# files
Write null-safe code that respects nullable annotations instead of suppressing warnings by default
Use the namespace patternGFramework.{Module}.{Feature}with PascalCase segments
Follow standard C# naming: Types, methods, properties, events, and con...
Files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
🧠 Learnings (24)
📓 Common learnings
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: CqrsHandlerRegistryGenerator must generate CQRS handler registries for consuming assemblies with runtime prioritization of generated products and fallback to reflection scanning; non-default assemblies must be explicitly registered via RegisterCqrsHandlersFromAssembly or RegisterCqrsHandlersFromAssemblies
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: CqrsHandlerRegistryGenerator must generate CQRS handler registries for consuming assemblies with runtime prioritization of generated products and fallback to reflection scanning; non-default assemblies must be explicitly registered via RegisterCqrsHandlersFromAssembly or RegisterCqrsHandlersFromAssemblies
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : When generator behavior changes intentionally, update snapshots together with the implementation
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : Keep source generators deterministic and free of hidden environment or network dependencies
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.Tests.cs : Source generator changes MUST be covered by generator tests
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: ContextAwareGenerator source generator with [ContextAware] attribute must automatically implement IContextAware boilerplate logic
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : Generated logic and generator pipelines MUST explain what is generated, why it is generated, the semantic assumptions the generator relies on, and any diagnostics or fallback behavior
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: Source Generators must target netstandard2.1 and provide incremental Roslyn code generation capabilities
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.Tests.cs : Preserve snapshot-based verification patterns already used in the repository for source generator tests
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : Preserve deterministic behavior in registries, lifecycle orchestration, and generated outputs
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : If a member participates in lifecycle, threading, registration, or disposal behavior, document that behavior explicitly in XML documentation
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-06T12:45:43.921Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:43.921Z
Learning: In the GeWuYou/GFramework repository, C# files may omit explicit `using System*` imports because the project-wide `GlobalUsings.cs` (referenced via manual global `using` directives) supplies common namespaces (e.g., `System`, `System.Threading`, `System.Threading.Tasks`). During code review, do not flag missing `using System...` directives in `.cs` files as long as `GlobalUsings.cs` is present/used to provide those namespaces.
Applied to files:
GFramework.Cqrs.SourceGenerators/Cqrs/CqrsHandlerRegistryGenerator.csGFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : Any change to public API, lifecycle semantics, module behavior, or extension points MUST update the related XML docs
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : Code should remain understandable without requiring external context. Prefer slightly more explanation over too little for framework code
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : 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.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : When adding caching, pooling, or shared mutable state, document thread-safety assumptions and failure modes
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.cs : XML documentation comments must explain intent, contract, and usage constraints instead of restating syntax
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs
📚 Learning: 2026-04-16T14:51:18.170Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-16T14:51:18.170Z
Learning: IContextAware must provide unified context access through SetContext(IArchitectureContext) method for all components
Applied to files:
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Public API changes must be covered by unit or integration tests
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Regression fixes should include a test that fails before the fix and passes after it
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : 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
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.cs : Keep tests focused on observable behavior, not implementation trivia
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.cs
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical
Applied to files:
GFramework.SourceGenerators.Tests/Cqrs/CqrsHandlerRegistryGeneratorTests.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.csGFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs
🔇 Additional comments (8)
GFramework.Core.SourceGenerators/Rule/ContextAwareGenerator.cs (4)
99-113: 类级别 XML 文档完整,清晰说明了生成实现与手动继承路径的差异。文档详尽描述了实例级缓存、静态提供者共享、以及与
ContextAwareBase无锁语义的对比,符合编码规范对生成器管道的文档要求。
146-186: Context 属性的双重检查锁定模式实现正确,文档充分说明了同步语义和潜在的死锁风险。
- 先读取
_context并在非空时快速返回,避免不必要的锁获取- 锁内使用
??=处理竞态条件- 文档明确警告自定义 provider 不应在
GetContext()调用链内重入配置 API 或形成反向锁顺序这解决了之前审查中提出的线程竞态问题。
188-222:SetContextProvider和ResetContextProvider的文档现在明确说明了缓存语义。文档已补充说明:
- 切换/重置提供者仅影响尚未初始化上下文的新实例
- 已缓存的实例上下文不会自动失效
- 如需覆盖已有实例的上下文,需显式调用
IContextAware.SetContext(...)这符合编码规范中"生命周期、线程、注册或处置行为必须在 XML 文档中显式记录"的要求,且解决了之前审查中提出的文档缺失问题。
290-296:SetContext方法体现在使用与 Context getter 相同的同步协议。生成的
SetContext实现已在_contextSync锁保护下赋值_context,避免显式注入被并发懒加载覆盖。这解决了之前审查中识别的线程竞态问题。GFramework.SourceGenerators.Tests/Rule/snapshots/ContextAwareGenerator/MyRule.ContextAware.g.cs (4)
1-20: 快照正确反映了生成器的同步实现。生成的代码包含:
- 实例级
_context字段- 静态共享
_contextProvider字段_contextSync锁对象用于协调所有共享状态的访问类级别文档清晰说明了与
ContextAwareBase的差异,符合 learnings 中"When generator behavior changes intentionally, update snapshots together with the implementation"的要求。
33-52: Context 属性的双重检查锁定模式实现正确。
- 第 37-41 行:先读取
_context快照并在非空时快速返回- 第 45-50 行:锁内使用
??=确保线程安全的懒加载- 内联注释准确描述了同步语义和对自定义 provider 的约束
这解决了之前审查中识别的并发竞态问题。
63-85:SetContextProvider和ResetContextProvider现在正确同步。两个方法都在
_contextSync锁内修改_contextProvider,与 Context getter 使用相同的同步协议,避免了提供者切换与惰性初始化的交错竞态。
87-99: 显式接口实现完整且线程安全。
IContextAware.SetContext在锁内赋值_context,与 getter 共享同步协议IContextAware.GetContext委托到 Context 属性,复用懒加载逻辑实现符合
IContextAware接口契约,且保持了线程安全性。
添加了完整的XML文档注释到Execute方法,详细说明了CQRS处理器注册生成器的执行流程、参数含义、实现逻辑和注意事项。同时改进了测试框架,在GeneratorExecutionResult中分离了生成代码的编译诊断,使测试能够更精确地验证生成代码的质量。
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary by CodeRabbit
新功能
改进
测试
杂项