docs(generators): 添加 Priority 和 Context Get 生成器文档#149
Conversation
- 新增 Priority 生成器文档,介绍自动实现 IPrioritized 接口的功能 - 新增 Context Get 注入生成器文档,说明自动注入架构组件的特性 - 更新索引页面,添加新生成器的导航链接和功能描述 - 补充 EnumGenerator 配置选项说明,列出已实现和未实现的选项 - 添加完整的诊断信息说明,涵盖新生成器的所有错误场景
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| C# | Mar 29, 2026 12:23p.m. | Review ↗ | |
| Secrets | Mar 29, 2026 12:23p.m. | Review ↗ |
审阅者指南为新的 Priority 和 Context Get 源生成器添加了完整的中文文档,将它们接入生成器索引(包括诊断和分析器行为),澄清了 EnumGenerator 已支持/未支持的选项,并为这些新生成器相关的所有诊断项编写了文档。 Context Get 注入与 __InjectContextBindings_Generated 的时序图sequenceDiagram
participant Architecture as Architecture
participant PlayerController as PlayerController
participant ContextGetGenerator as ContextGetGenerator
rect rgb(230,230,230)
ContextGetGenerator->>ContextGetGenerator: Analyze PlayerController fields
ContextGetGenerator->>ContextGetGenerator: Detect GetModel GetSystem GetUtility GetService attributes
ContextGetGenerator->>PlayerController: Generate __InjectContextBindings_Generated()
end
PlayerController->>PlayerController: __InjectContextBindings_Generated()
PlayerController->>Architecture: GetModel~IPlayerModel~()
Architecture-->>PlayerController: IPlayerModel instance
PlayerController->>PlayerController: assign _playerModel
PlayerController->>Architecture: GetSystem~ICombatSystem~()
Architecture-->>PlayerController: ICombatSystem instance
PlayerController->>PlayerController: assign _combatSystem
PlayerController->>Architecture: GetUtility~IPathFinder~()
Architecture-->>PlayerController: IPathFinder instance
PlayerController->>PlayerController: assign _pathFinder
PlayerController->>Architecture: GetService~IAudioService~()
Architecture-->>PlayerController: IAudioService instance
PlayerController->>PlayerController: assign _audioService
PlayerController->>PlayerController: Initialize() uses injected fields
基于 Priority 的检索与分析器推荐的时序图sequenceDiagram
participant Architecture as Architecture
participant GameArchitecture as GameArchitecture
participant SystemA as InputSystem
participant SystemB as PhysicsSystem
participant SystemC as GameplaySystem
participant PriorityUsageAnalyzer as PriorityUsageAnalyzer
rect rgb(230,230,230)
PriorityUsageAnalyzer->>GameArchitecture: Inspect call GetAll~ISystem~()
PriorityUsageAnalyzer-->>GameArchitecture: Diagnostic GF_Priority_Usage_001
end
GameArchitecture->>Architecture: GetAllByPriority~ISystem~()
Architecture->>SystemA: read Priority
Architecture->>SystemB: read Priority
Architecture->>SystemC: read Priority
Architecture-->>GameArchitecture: List~ISystem~ sortedByPriority
loop ForEach system in sorted list
GameArchitecture->>SystemA: Init()
GameArchitecture->>SystemB: Init()
GameArchitecture->>SystemC: Init()
end
Priority 生成器与 IPrioritized 生态的类图classDiagram
class IPrioritized {
+int Priority
}
class PriorityAttribute {
+int value
}
class PriorityGroup {
+const int Critical
+const int High
+const int Normal
+const int Low
+const int Deferred
}
class AbstractSystem {
<<abstract>>
+void Init()
+void InitAsync()
}
class InputSystem {
+void OnInit()
}
class PhysicsSystem {
+void OnInit()
}
class GameplaySystem {
+void OnInit()
}
class AudioSystem {
+void OnInit()
}
class CleanupSystem {
+void OnInit()
}
class Architecture {
+List~T~ GetAll~T~()
+List~T~ GetAllByPriority~T~()
}
class PriorityGenerator {
+void Execute()
}
class PriorityUsageAnalyzer {
+void AnalyzeInvocation()
}
PriorityAttribute o-- PriorityGroup : uses
PriorityAttribute ..> IPrioritized : generates_implementation
IPrioritized <|.. AbstractSystem
AbstractSystem <|-- InputSystem
AbstractSystem <|-- PhysicsSystem
AbstractSystem <|-- GameplaySystem
AbstractSystem <|-- AudioSystem
AbstractSystem <|-- CleanupSystem
Architecture ..> IPrioritized : GetAllByPriority
PriorityGenerator ..> PriorityAttribute : reads
PriorityGenerator ..> IPrioritized : implements
PriorityUsageAnalyzer ..> Architecture : inspects_GetAll
PriorityUsageAnalyzer ..> IPrioritized : detects_usage
Context Get 注入与 ContextAware 生态的类图classDiagram
class IContextAware {
+IArchitecture Architecture
+void SetContextProvider(IContextProvider provider)
}
class ContextAwareAttribute {
}
class ContextAwareBase {
+IArchitecture Architecture
+void SetContextProvider(IContextProvider provider)
}
class IArchitecture {
+T GetModel~T~()
+IReadOnlyList~T~ GetModels~T~()
+T GetSystem~T~()
+IReadOnlyList~T~ GetSystems~T~()
+T GetUtility~T~()
+IReadOnlyList~T~ GetUtilities~T~()
+T GetService~T~()
+IReadOnlyList~T~ GetServices~T~()
}
class IModel {
}
class ISystem {
}
class IUtility {
}
class GetModelAttribute {
}
class GetModelsAttribute {
}
class GetSystemAttribute {
}
class GetSystemsAttribute {
}
class GetUtilityAttribute {
}
class GetUtilitiesAttribute {
}
class GetServiceAttribute {
}
class GetServicesAttribute {
}
class GetAllAttribute {
}
class PlayerController {
-IPlayerModel _playerModel
-ICombatSystem _combatSystem
-IPathFinder _pathFinder
-IAudioService _audioService
-void __InjectContextBindings_Generated()
+void Initialize()
}
IContextAware <|.. ContextAwareBase
ContextAwareAttribute ..> IContextAware : marks
IArchitecture ..> IModel
IArchitecture ..> ISystem
IArchitecture ..> IUtility
GetModelAttribute ..> IModel : target_type
GetModelsAttribute ..> IModel : collection_type
GetSystemAttribute ..> ISystem : target_type
GetSystemsAttribute ..> ISystem : collection_type
GetUtilityAttribute ..> IUtility : target_type
GetUtilitiesAttribute ..> IUtility : collection_type
GetServiceAttribute ..> IArchitecture : target_type
GetServicesAttribute ..> IArchitecture : collection_type
GetAllAttribute ..> IModel : infers
GetAllAttribute ..> ISystem : infers
GetAllAttribute ..> IUtility : infers
PlayerController ..|> IContextAware
PlayerController ..> GetModelAttribute
PlayerController ..> GetSystemAttribute
PlayerController ..> GetUtilityAttribute
PlayerController ..> GetServiceAttribute
PlayerController ..> GetAllAttribute
文件级变更
提示与命令与 Sourcery 交互
自定义体验打开你的 dashboard 以:
获取帮助Original review guide in EnglishReviewer's GuideAdds comprehensive Chinese documentation for the new Priority and Context Get source generators, wires them into the generators index (including diagnostics and analyzer behavior), clarifies supported/unsupported EnumGenerator options, and documents all related diagnostics for the new generators. Sequence diagram for Context Get injection and __InjectContextBindings_GeneratedsequenceDiagram
participant Architecture as Architecture
participant PlayerController as PlayerController
participant ContextGetGenerator as ContextGetGenerator
rect rgb(230,230,230)
ContextGetGenerator->>ContextGetGenerator: Analyze PlayerController fields
ContextGetGenerator->>ContextGetGenerator: Detect GetModel GetSystem GetUtility GetService attributes
ContextGetGenerator->>PlayerController: Generate __InjectContextBindings_Generated()
end
PlayerController->>PlayerController: __InjectContextBindings_Generated()
PlayerController->>Architecture: GetModel~IPlayerModel~()
Architecture-->>PlayerController: IPlayerModel instance
PlayerController->>PlayerController: assign _playerModel
PlayerController->>Architecture: GetSystem~ICombatSystem~()
Architecture-->>PlayerController: ICombatSystem instance
PlayerController->>PlayerController: assign _combatSystem
PlayerController->>Architecture: GetUtility~IPathFinder~()
Architecture-->>PlayerController: IPathFinder instance
PlayerController->>PlayerController: assign _pathFinder
PlayerController->>Architecture: GetService~IAudioService~()
Architecture-->>PlayerController: IAudioService instance
PlayerController->>PlayerController: assign _audioService
PlayerController->>PlayerController: Initialize() uses injected fields
Sequence diagram for Priority based retrieval and analyzer recommendationsequenceDiagram
participant Architecture as Architecture
participant GameArchitecture as GameArchitecture
participant SystemA as InputSystem
participant SystemB as PhysicsSystem
participant SystemC as GameplaySystem
participant PriorityUsageAnalyzer as PriorityUsageAnalyzer
rect rgb(230,230,230)
PriorityUsageAnalyzer->>GameArchitecture: Inspect call GetAll~ISystem~()
PriorityUsageAnalyzer-->>GameArchitecture: Diagnostic GF_Priority_Usage_001
end
GameArchitecture->>Architecture: GetAllByPriority~ISystem~()
Architecture->>SystemA: read Priority
Architecture->>SystemB: read Priority
Architecture->>SystemC: read Priority
Architecture-->>GameArchitecture: List~ISystem~ sortedByPriority
loop ForEach system in sorted list
GameArchitecture->>SystemA: Init()
GameArchitecture->>SystemB: Init()
GameArchitecture->>SystemC: Init()
end
Class diagram for Priority generator and IPrioritized ecosystemclassDiagram
class IPrioritized {
+int Priority
}
class PriorityAttribute {
+int value
}
class PriorityGroup {
+const int Critical
+const int High
+const int Normal
+const int Low
+const int Deferred
}
class AbstractSystem {
<<abstract>>
+void Init()
+void InitAsync()
}
class InputSystem {
+void OnInit()
}
class PhysicsSystem {
+void OnInit()
}
class GameplaySystem {
+void OnInit()
}
class AudioSystem {
+void OnInit()
}
class CleanupSystem {
+void OnInit()
}
class Architecture {
+List~T~ GetAll~T~()
+List~T~ GetAllByPriority~T~()
}
class PriorityGenerator {
+void Execute()
}
class PriorityUsageAnalyzer {
+void AnalyzeInvocation()
}
PriorityAttribute o-- PriorityGroup : uses
PriorityAttribute ..> IPrioritized : generates_implementation
IPrioritized <|.. AbstractSystem
AbstractSystem <|-- InputSystem
AbstractSystem <|-- PhysicsSystem
AbstractSystem <|-- GameplaySystem
AbstractSystem <|-- AudioSystem
AbstractSystem <|-- CleanupSystem
Architecture ..> IPrioritized : GetAllByPriority
PriorityGenerator ..> PriorityAttribute : reads
PriorityGenerator ..> IPrioritized : implements
PriorityUsageAnalyzer ..> Architecture : inspects_GetAll
PriorityUsageAnalyzer ..> IPrioritized : detects_usage
Class diagram for Context Get injection and ContextAware ecosystemclassDiagram
class IContextAware {
+IArchitecture Architecture
+void SetContextProvider(IContextProvider provider)
}
class ContextAwareAttribute {
}
class ContextAwareBase {
+IArchitecture Architecture
+void SetContextProvider(IContextProvider provider)
}
class IArchitecture {
+T GetModel~T~()
+IReadOnlyList~T~ GetModels~T~()
+T GetSystem~T~()
+IReadOnlyList~T~ GetSystems~T~()
+T GetUtility~T~()
+IReadOnlyList~T~ GetUtilities~T~()
+T GetService~T~()
+IReadOnlyList~T~ GetServices~T~()
}
class IModel {
}
class ISystem {
}
class IUtility {
}
class GetModelAttribute {
}
class GetModelsAttribute {
}
class GetSystemAttribute {
}
class GetSystemsAttribute {
}
class GetUtilityAttribute {
}
class GetUtilitiesAttribute {
}
class GetServiceAttribute {
}
class GetServicesAttribute {
}
class GetAllAttribute {
}
class PlayerController {
-IPlayerModel _playerModel
-ICombatSystem _combatSystem
-IPathFinder _pathFinder
-IAudioService _audioService
-void __InjectContextBindings_Generated()
+void Initialize()
}
IContextAware <|.. ContextAwareBase
ContextAwareAttribute ..> IContextAware : marks
IArchitecture ..> IModel
IArchitecture ..> ISystem
IArchitecture ..> IUtility
GetModelAttribute ..> IModel : target_type
GetModelsAttribute ..> IModel : collection_type
GetSystemAttribute ..> ISystem : target_type
GetSystemsAttribute ..> ISystem : collection_type
GetUtilityAttribute ..> IUtility : target_type
GetUtilitiesAttribute ..> IUtility : collection_type
GetServiceAttribute ..> IArchitecture : target_type
GetServicesAttribute ..> IArchitecture : collection_type
GetAllAttribute ..> IModel : infers
GetAllAttribute ..> ISystem : infers
GetAllAttribute ..> IUtility : infers
PlayerController ..|> IContextAware
PlayerController ..> GetModelAttribute
PlayerController ..> GetSystemAttribute
PlayerController ..> GetUtilityAttribute
PlayerController ..> GetServiceAttribute
PlayerController ..> GetAllAttribute
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
嗨,我这边有一些整体性的反馈:
- The diagnostic sections for Priority 和 Context Get 在 index.md 与各自的专用文档中存在较大重复,建议保留一处为权威来源并在另一处做简化或链接引用,以便后续规则变更时减少同步维护成本。
- Context Get 的示例中
__InjectContextBindings_Generated()的调用方式比较分散(构造函数、_Ready、Initialize 等),可以在文档中集中增加一小节明确推荐的调用时机和模式,避免读者误以为可以在构造函数体中使用尚未注入的字段。
给 AI Agents 的提示
请根据本次代码评审中的评论进行修改:
## 总体评论
- The diagnostic sections for Priority 和 Context Get 在 index.md 与各自的专用文档中存在较大重复,建议保留一处为权威来源并在另一处做简化或链接引用,以便后续规则变更时减少同步维护成本。
- Context Get 的示例中 `__InjectContextBindings_Generated()` 的调用方式比较分散(构造函数、_Ready、Initialize 等),可以在文档中集中增加一小节明确推荐的调用时机和模式,避免读者误以为可以在构造函数体中使用尚未注入的字段。帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进评审质量。
Original comment in English
Hey - I've left some high level feedback:
- The diagnostic sections for Priority 和 Context Get 在 index.md 与各自的专用文档中存在较大重复,建议保留一处为权威来源并在另一处做简化或链接引用,以便后续规则变更时减少同步维护成本。
- Context Get 的示例中
__InjectContextBindings_Generated()的调用方式比较分散(构造函数、_Ready、Initialize 等),可以在文档中集中增加一小节明确推荐的调用时机和模式,避免读者误以为可以在构造函数体中使用尚未注入的字段。
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The diagnostic sections for Priority 和 Context Get 在 index.md 与各自的专用文档中存在较大重复,建议保留一处为权威来源并在另一处做简化或链接引用,以便后续规则变更时减少同步维护成本。
- Context Get 的示例中 `__InjectContextBindings_Generated()` 的调用方式比较分散(构造函数、_Ready、Initialize 等),可以在文档中集中增加一小节明确推荐的调用时机和模式,避免读者误以为可以在构造函数体中使用尚未注入的字段。Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
- 实现 safeGenericEscapePlugin 插件保护 Markdown 中的泛型语法 - 配置 Vite 构建选项提高代码块大小警告阈值至 1000 - 添加 Priority 生成器和 Context Get 注入文档链接 - 重构配置文件结构将插件函数移至顶部定义 - 确保代码块和 HTML 标签在转义过程中得到正确保护
- 在多个示例中添加 __InjectContextBindings_Generated() 调用 - 重写推荐调用时机与模式章节,强调在生命周期入口统一调用 - 添加 Godot 节点和测试场景的具体使用模式 - 重构诊断信息表格,整合 Priority 和 Context Get 相关诊断 - 更新 FAQ 部分关于构造函数使用的建议
Summary by Sourcery
为 Priority 和 Context Get 源生成器及其诊断编写文档,并明确 EnumGenerator 的配置选项。
Documentation:
Original summary in English
Summary by Sourcery
Document Priority and Context Get source generators and their diagnostics, and clarify EnumGenerator configuration options.
Documentation: