Repository navigation
fix: 载体程序集装进核心所在的装载上下文 - #40
Conversation
真机验收抓到的:Endstone 载体带 bootstrap 时启动即失败——配置器类型取不到。 两处原因都在装载上下文与装配方式: - 原生宿主经 hostfxr 的组件方式起核心,核心落在 IsolatedComponentLoadContext, Hosihikari.Plugin.Abstractions 这类依赖只在那个上下文里;按路径装程序集却用 的是默认上下文,bootstrap 的类型因此解析不到它的依赖(GetType 抛 FileNotFoundException,被 throwOnError:false 吞成 null)。 - 原先走 Assembly.LoadFrom:它挂的是包目录探测,会把上下文里已经有的契约再装 一份,同名类型于是有两个类型对象,ICarrierServicesConfigurator 转型失败。 改为在核心自己所在的上下文里装,并先按简单名认已装的那份;组件的解析也走同 一条规则,不再各写一遍。宿主断言跑在默认上下文,复现不出这条,靠实机验收守。
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a564e9d765
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return File.Exists(path) | ||
| ? Assembly.LoadFrom(path) | ||
| : Assembly.Load(new AssemblyName(Path.GetFileNameWithoutExtension(fileName))); | ||
| ? context.LoadFromAssemblyPath(Path.GetFullPath(path)) |
There was a problem hiding this comment.
Preserve package-local dependency probing in the core context
When a carrier bootstrap or component references a private DLL shipped beside it but absent from the core's dependency graph and carrier.sharedAssemblies, switching from Assembly.LoadFrom to LoadFromAssemblyPath removes the sibling-directory dependency probing. Loading the entry assembly succeeds, but resolving or executing its types can now throw FileNotFoundException, causing TryConfigure or StartComponents to reject the carrier. These packages are supported by Packager.ValidateCarrier, which resolves against all package DLLs, and the packer copies those dependencies into the package. Keep loading into the core context, but add package-local dependency resolution that reuses already-loaded contracts.
Useful? React with 👍 / 👎.
按路径装载不挂包目录探测,包里只住在载体目录、又不在共享层清单里的私有 DLL 会解析不到(Codex 评审在 #40 上指出)。在核心所在的上下文上补一个 Resolving 解析器:只有正常解析失败才轮到它,命中包内文件才装;已装着的 契约仍是一份,不会装出第二个类型对象。
|
Codex 的 P2 已修(e9d3f88): |
真机验收抓到的缺陷:载体包声明
carrier.bootstrap时,Endstone 载体启动即失败,日志报「载体引导 … 不是带公开无参构造的 ICarrierServicesConfigurator」。两处原因都在装载上下文与装配方式:
IsolatedComponentLoadContext;Hosihikari.Plugin.Abstractions这些依赖只在那张表上。按路径装程序集却走默认上下文,bootstrap 的类型因此解析不到它的依赖——GetType(..., throwOnError: false)把FileNotFoundException吞成null,报出来就成了"不是配置器"。Assembly.LoadFrom:它挂的是包目录探测,会把上下文里已经有的契约再装一份,同名类型于是有两个类型对象,ICarrierServicesConfigurator转型失败。改法:
CarrierStartup.ResolveAssembly在核心自己所在的上下文里装,并先按简单名认已装的那份;StartComponents的组件解析走同一条规则,不再各写一遍。验证
宿主断言跑在默认上下文,复现不出这条;守它的是实机验收。