test(godot): 补强日志反射断言

- 补充 GodotLogger 结构化属性反射目标的显式断言

- 优化 反射返回类型不匹配时的测试失败定位

- 更新 godot logging core sink 跟踪与执行 trace
This commit is contained in:
gewuyou 2026-05-03 14:04:59 +08:00
parent 3ced56be8b
commit 64e5d8d11d
3 changed files with 42 additions and 6 deletions

View File

@ -195,6 +195,8 @@ public sealed class GodotLoggerSettingsLoaderTests
var toPropertiesDictionary = typeof(GodotLogger).GetMethod(
"ToPropertiesDictionary",
BindingFlags.NonPublic | BindingFlags.Static);
Assert.That(toPropertiesDictionary, Is.Not.Null, "Unable to reflect GodotLogger.ToPropertiesDictionary.");
var properties = new (string Key, object? Value)[]
{
(null!, "ignored"),
@ -202,7 +204,9 @@ public sealed class GodotLoggerSettingsLoaderTests
(" Player ", 42)
};
var dictionary = toPropertiesDictionary?.Invoke(null, [properties]) as IReadOnlyDictionary<string, object?>;
var dictionary = toPropertiesDictionary!.Invoke(null, [properties]) as IReadOnlyDictionary<string, object?>;
Assert.That(dictionary, Is.Not.Null, "ToPropertiesDictionary should return structured log properties.");
var result = GodotLogAppender.FormatProperties(dictionary);
Assert.That(result, Is.EqualTo(" | Player=42"));

View File

@ -7,13 +7,14 @@
## 当前恢复点
- 恢复点编号:`GODOT-LOGGING-CORE-SINK-RP-003`
- 当前阶段:`PR review follow-up 已验证`
- 恢复点编号:`GODOT-LOGGING-CORE-SINK-RP-004`
- 当前阶段:`PR review follow-up 复查已验证`
- 当前焦点:
- `GFramework.Godot.Logging.GodotLogAppender` 已作为 Core `ILogAppender` 的 Godot 宿主落点落地
- `GodotLogger` 保留原有 `ILogger` 入口,但底层输出委托给 appender
- Godot / Core logging 文档已说明 provider 与 appender 的组合边界
- PR #315 最新 AI review 中仍适用的测试稳定性、dead private wrapper、boot index 与 trace heading 问题已处理
- 最新 CodeRabbit outside-diff 复查指出的反射测试诊断不清晰问题已处理
## 已知输入
@ -31,7 +32,8 @@
3. 已完成:保留 `GodotLog` / `GodotLoggerFactoryProvider` 入口,并让 `GodotLogger` 底层走 `GodotLogAppender`
4. 已完成:补充 `GodotLogAppender` targeted tests 与 `docs/zh-CN/` adoption guidance
5. 已完成:处理 PR #315 最新 review follow-up移除默认 boot index 的 archived topics 区块并消除 trace 重复 heading
6. 待确认:是否还需要在后续阶段补一个配置化 factory 示例,把 `GodotLogAppender` 与文件 / async appender 显式组合
6. 已完成:处理最新 CodeRabbit outside-diff 反馈,显式断言反射目标与返回类型以改善测试失败定位
7. 待确认:是否还需要在后续阶段补一个配置化 factory 示例,把 `GodotLogAppender` 与文件 / async appender 显式组合
## 验证
@ -48,12 +50,18 @@
- 结果:通过
- `dotnet format GFramework.Godot.Tests --verify-no-changes --no-restore --include GFramework.Godot.Tests/Logging/GodotLogAppenderTests.cs GFramework.Godot.Tests/Logging/GodotLoggerSettingsLoaderTests.cs`
- 结果:通过
- `dotnet test GFramework.Godot.Tests -c Release`
- 结果:通过,`75 passed / 0 failed / 0 skipped`
- 备注2026-05-03 最新 PR review outside-diff 复查后重新验证
- `dotnet format GFramework.Godot.Tests --verify-no-changes --no-restore --include GFramework.Godot.Tests/Logging/GodotLoggerSettingsLoaderTests.cs`
- 结果:通过
- 备注:覆盖最新改动的测试文件
- `dotnet format GFramework.sln --verify-no-changes --no-restore`
- 结果:失败
- 备注:失败集中在仓库既有的 whitespace、final newline 与 charset 诊断,跨 `GFramework.Core``GFramework.Cqrs``GFramework.Game.Abstractions` 等未触碰项目;本轮改动用 scoped format 验证
## 下一步
1. 提交当前 PR review follow-up
2. 等待 PR #315 复查并确认 CodeRabbit / Greptile 线程是否关闭
1. 提交最新 PR review follow-up
2. 等待 PR #315 复查并确认 CodeRabbit outside-diff 反馈是否关闭
3. 如继续扩展本主题,优先评估是否需要示例化 `CompositeLogger + GodotLogAppender + FileAppender`,而不是新增 API

View File

@ -91,3 +91,27 @@
1. 提交 PR review follow-up
2. 等待 PR #315 复查,确认 CodeRabbit / Greptile open threads 是否关闭
### RP-004 PR Review Outside-Diff 复查
- 使用 `$gframework-pr-review` 重新抓取 PR #315 最新 review payload
- CodeRabbit无 open thread但 latest review body 仍有 1 条 outside-diff 反馈
- Greptile无 open thread
- Gemini Code Assist无 open thread
- GitHub Test Reporter最新 run 显示 `2264 passed / 0 failed`
- MegaLinter仍为 `dotnet-format` restore failure未提供具体源文件格式诊断
- 已实施:
- `GodotLoggerSettingsLoaderTests.StructuredProperties_Should_Skip_Blank_Keys_And_Trim_Valid_Keys` 在调用反射目标前显式断言 `ToPropertiesDictionary` 存在
- 同一测试在交给 `GodotLogAppender.FormatProperties` 前显式断言反射返回值类型符合预期
### RP-004 验证
- `dotnet test GFramework.Godot.Tests -c Release`
- 结果:通过,`75 passed / 0 failed / 0 skipped`
- `dotnet format GFramework.Godot.Tests --verify-no-changes --no-restore --include GFramework.Godot.Tests/Logging/GodotLoggerSettingsLoaderTests.cs`
- 结果:通过
### RP-004 下一步
1. 提交最新 PR review follow-up
2. 等待 PR #315 复查,确认 CodeRabbit outside-diff 反馈是否关闭