docs(generator): 添加源码生成器文档和分析器规则清单

- 新增 AnalyzerReleases.Unshipped.md 文件记录代码分析规则
- 添加 GF_Godot_GetNode 系列规则定义(001-006)
- 添加 GF_Godot_BindNodeSignal 系列规则定义(001-009)
- 创建 README.md 文件详述源码生成器使用方法
- 文档化 GetNode 和 BindNodeSignal 特性用法示例
- 说明 Godot 场景相关的编译期生成能力
This commit is contained in:
GeWuYou 2026-03-31 10:03:31 +08:00
parent 5b996d8618
commit 9cca190aff
2 changed files with 62 additions and 8 deletions

View File

@ -4,10 +4,19 @@
### New Rules
Rule ID | Category | Severity | Notes
----------------------|------------------|----------|--------------------
-----------------------------|------------------|----------|---------------------------
GF_Godot_GetNode_001 | GFramework.Godot | Error | GetNodeDiagnostics
GF_Godot_GetNode_002 | GFramework.Godot | Error | GetNodeDiagnostics
GF_Godot_GetNode_003 | GFramework.Godot | Error | GetNodeDiagnostics
GF_Godot_GetNode_004 | GFramework.Godot | Error | GetNodeDiagnostics
GF_Godot_GetNode_005 | GFramework.Godot | Error | GetNodeDiagnostics
GF_Godot_GetNode_006 | GFramework.Godot | Warning | GetNodeDiagnostics
GF_Godot_BindNodeSignal_001 | GFramework.Godot | Error | BindNodeSignalDiagnostics
GF_Godot_BindNodeSignal_002 | GFramework.Godot | Error | BindNodeSignalDiagnostics
GF_Godot_BindNodeSignal_003 | GFramework.Godot | Error | BindNodeSignalDiagnostics
GF_Godot_BindNodeSignal_004 | GFramework.Godot | Error | BindNodeSignalDiagnostics
GF_Godot_BindNodeSignal_005 | GFramework.Godot | Error | BindNodeSignalDiagnostics
GF_Godot_BindNodeSignal_006 | GFramework.Godot | Error | BindNodeSignalDiagnostics
GF_Godot_BindNodeSignal_007 | GFramework.Godot | Error | BindNodeSignalDiagnostics
GF_Godot_BindNodeSignal_008 | GFramework.Godot | Warning | BindNodeSignalDiagnostics
GF_Godot_BindNodeSignal_009 | GFramework.Godot | Warning | BindNodeSignalDiagnostics

View File

@ -7,6 +7,7 @@
- 与 Godot 场景相关的编译期生成能力
- 基于 Roslyn 的增量生成器实现
- `[GetNode]` 字段注入,减少 `_Ready()` 里的 `GetNode<T>()` 样板代码
- `[BindNodeSignal]` 方法绑定,减少 `_Ready()` / `_ExitTree()` 中重复的事件订阅样板代码
## 使用建议
@ -43,3 +44,47 @@ public partial class TopBar : HBoxContainer
- `_leftContainer` -> `%LeftContainer`
- `m_rightContainer` -> `%RightContainer`
## BindNodeSignal 用法
```csharp
using GFramework.Godot.SourceGenerators.Abstractions;
using Godot;
public partial class Hud : Control
{
[GetNode]
private Button _startButton = null!;
[GetNode]
private SpinBox _startOreSpinBox = null!;
[BindNodeSignal(nameof(_startButton), nameof(Button.Pressed))]
private void OnStartButtonPressed()
{
}
[BindNodeSignal(nameof(_startOreSpinBox), nameof(SpinBox.ValueChanged))]
private void OnStartOreValueChanged(double value)
{
}
public override void _Ready()
{
__InjectGetNodes_Generated();
__BindNodeSignals_Generated();
}
public override void _ExitTree()
{
__UnbindNodeSignals_Generated();
}
}
```
生成器会产出两个辅助方法:
- `__BindNodeSignals_Generated()`:负责统一订阅事件
- `__UnbindNodeSignals_Generated()`:负责统一解绑事件
当前设计只处理 CLR event 形式的 Godot 事件绑定,不会自动调用 `Connect()` / `Disconnect()`