Skip to content

fix(capability-hosting): 类型扫描失败纳入装配问题清单并保留加载原因 - #642

Merged
AlianBlank merged 2 commits into
mainfrom
fix/capability-type-scan-failure-problems
Oct 25, 2026
Merged

AlianBlank merged 2 commits into
mainfrom
fix/capability-type-scan-failure-problems

Conversation

@AlianBlank

@AlianBlank AlianBlank commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

变更摘要

  • CapabilityAssembly.CollectModuleTypes 捕获 ReflectionTypeLoadException 时,由抛 InvalidOperationException 改为抛 CapabilityAssemblyException。
  • Problems 首条为 ModuleTypeScanFailed 定位信息(程序集名 + 失败个数),其后逐条保留每个 LoaderExceptions 的 Message;LoaderExceptions 为 null 时按空数组处理。
  • CapabilityAssemblyException 新增 (problems, innerException) 构造函数,重新封装时保留原始 ReflectionTypeLoadException(采纳 CodeRabbit 建议),调用方可检查原始堆栈与 LoaderExceptions 对象。
  • DiscoverModules → DiscoverFromDeploymentDirectory 无中间捕获,异常直达 CapabilityComposition.Compose 的 catch (CapabilityAssemblyException),经 RenderFailures 逐条打 Error 后再抛出。
  • 同 Id 多实现路径仍抛 InvalidOperationException,不在本次范围。

测试

  • DiscoverModules_UnloadableTypes_FailsFastWithAssemblyName 改为断言 CapabilityAssemblyException:首条含程序集名,后续条目含缺失依赖名,InnerException 为 ReflectionTypeLoadException。
  • dotnet test --filter FullyQualifiedName~GameFrameX.Tests.Online:930 通过 / 0 失败。
  • 未单独用残缺程序集端到端跑 Compose,传播链经代码阅读确认。

CollectModuleTypes 在 ReflectionTypeLoadException 时原先抛
InvalidOperationException,Compose 只捕获 CapabilityAssemblyException,
导致 RenderFailures 不打 Error 且仅剩失败个数、丢失具体原因。

改为抛 CapabilityAssemblyException:首条为程序集定位信息,其后逐条
保留 LoaderExceptions 的 Message;同步调整扫描失败用例断言。
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 827b978c-b416-48f6-bfef-b6e5b214d0b1
Commits

Reviewing files that changed from the base of the PR and between 08714df and cca6192.

Files selected for processing: 3
  • Capability/GameFrameX.Capability.Hosting.Core/CapabilityAssembly.cs
  • Capability/GameFrameX.Capability.Hosting.Core/CapabilityAssemblyException.cs
  • Tests/GameFrameX.Tests/Online/CapabilityDeploymentDiscoveryTests.cs
Walkthrough

程序集类型无法完整加载时,CollectModuleTypes 现在抛出 CapabilityAssemblyException,并在问题列表中保留程序集信息和各条非空加载异常消息。DiscoverModules 的文档和相关测试已同步更新。

Changes: 模块类型扫描异常处理

层 / 文件 摘要
扫描失败信息与验证
Capability/GameFrameX.Capability.Hosting.Core/CapabilityAssembly.cs, Tests/GameFrameX.Tests/Online/CapabilityDeploymentDiscoveryTests.cs
CollectModuleTypes 将程序集信息及非空加载异常消息加入问题列表,并抛出 CapabilityAssemblyException。DiscoverModules 文档和测试同步说明并验证异常类型及问题内容。

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • CollectModuleTypes 加载失败处理:相关问题指出此处会吞掉 ReflectionTypeLoadException,并要求保留加载或类型收集失败信息。本次改动覆盖类型收集失败的异常报告,但不涉及 LoadDeploymentAssemblies 路径。

Possibly related PRs

  • GameFrameX/GameFrameX.Server.Source#640:该 PR 引入了本次修改的代码路径和测试。本次改动调整同一测试,并将扫描失败异常改为 CapabilityAssemblyException,同时保留各条加载器异常消息。
Merge Risk: Minimal · up to 08714

No concrete merge-blocking risk remains after the available checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题准确概括了主要变更:类型扫描失败改用装配问题清单,并保留底层加载原因。标题简洁、明确,且与代码和测试变更一致。
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔇 Additional comments: 1
Capability/GameFrameX.Capability.Hosting.Core/CapabilityAssembly.cs: 1

160-160: Trivial · Maintainability & Code Quality · Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

保留原始类型加载异常。

Problems 现在保留了加载异常的消息,但此处新建的异常没有保留 ReflectionTypeLoadException。调用方因此无法检查原始堆栈或 LoaderExceptions 中的异常对象。请为 CapabilityAssemblyException 增加接收内部异常的构造函数,并在此处传入 exception;保留现有的 Problems 输出。根据已检索的经验,重新封装异常时应保留原始异常以支持诊断。

Source: Learnings


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c83262ac-301f-4d33-a1b6-d38f652278b3
Commits

Reviewing files that changed from the base of the PR and between e5b3662 and 08714df.

Files selected for processing: 2
  • Capability/GameFrameX.Capability.Hosting.Core/CapabilityAssembly.cs
  • Tests/GameFrameX.Tests/Online/CapabilityDeploymentDiscoveryTests.cs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

CapabilityAssemblyException 新增接收内部异常的构造函数,CollectModuleTypes
重新封装时传入原始异常,调用方可检查原始堆栈与 LoaderExceptions 对象;
Problems 输出保持不变。
@sonarqubecloud

Copy link
Copy Markdown

@AlianBlank
AlianBlank merged commit 70b04e0 into main Oct 25, 2026
3 checks passed
@AlianBlank
AlianBlank deleted the fix/capability-type-scan-failure-problems branch October 25, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant