feat: harden NativeAOT source generator coverage#402
Merged
Conversation
liuhaoyang
commented
Jul 24, 2026
liuhaoyang
left a comment
Member
Author
There was a problem hiding this comment.
评审总结
方向正确:把 byref-like 参数/返回值的运行时 InvalidProgramException 前移到编译期诊断(ACSG010/ACSG011),并为 NativeAOT 路径建立独立覆盖率门禁。诊断逻辑、规则抽取、测试覆盖都比较扎实。
合入前建议优先处理下面 P1 两项(Debug 构建断、覆盖率取整误杀),P2 的路径匹配最好在 CI 上跑一次确认。其余为可跟进改进项。
Thursday 修复后我再来复审。
liuhaoyang
commented
Jul 24, 2026
liuhaoyang
left a comment
Member
Author
There was a problem hiding this comment.
复审结论:5 条 review 全部解决 ✅
逐项核对了 7a114c0 fix: address nativeaot coverage review feedback 的 diff:
P1 — AssemblyInfo.cs 缺 #if DEBUG ✅ 已解决
补了 #if DEBUG 无 key IVT + #else 带 public key IVT,与 AspectCore.Core/Properties/AssemblyInfo.cs 模式一致。Debug SourceGeneratorDiagnosticTests 8/8 pass 验证了这一点。
P1 — 覆盖率整数除法截断 ✅ 已解决
coverage_from_cobertura改为f"{covered * 100 / valid:.2f}",输出两位小数。- 新增
coverage_passed用coverage + 1e-9 >= threshold浮点比较,避免边界误杀。 assert_coverage把^[0-9]+$校验换成coverage_is_number,支持小数。- 非 NativeAOT 路径用
root_line_rate+printf '%.0f'保持原整数行为,向后兼容。 - 本地验证 100.00%/100%、97.86%/95% 均 pass。
P2 — scope 路径与 Cobertura filename 不匹配 ✅ 已解决
- 新增
matches_scope:支持 exact match +/suffix+\suffix,兼容 coverlet 不同路径格式。 - CI 日志输出
Scope matched classes: N及文件名,便于排障。 - 本地验证匹配到 3 个目标文件。
P2 — execution check 结论写死 success / 标题 passed ✅ 已解决
- 标题改为
NativeAOT Test Execution: collected (UT x%, E2E y%)。 - summary 文案明确说明「Threshold enforcement is reported by the NativeAOT Coverage check」,不再误导。
P3 — 只报第一个 byref-like 参数 ✅ 已解决(按建议保留行为 + 注释)
在 NativeAotSignatureDiagnosticRules.Analyze 的 FirstOrDefault 上方补了注释,说明是刻意设计、保持诊断聚焦并沿用已有 params 行为。
额外观察(非阻塞,可后续跟进)
coverage_from_cobertura在scope_files为空时也会打印Scope matched classes调试行,对非 NativeAOT 路径无影响(该函数只在 NativeAOT 模式调用),但如果以后复用要注意。integer_average用int(sum // len)截断而非四舍五入,与原bash整数除法行为一致,OK。
修复质量很好,覆盖率脚本重构后更健壮(去掉了 bc 依赖、统一用 Python 处理浮点)。没有新的阻塞问题。
latte-gh
enabled auto-merge (squash)
July 24, 2026 15:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification