feat: 公开宿主组合加载 API、Forge 风格依赖版本区间与加载顺序、程序集解析策略
- ShrinkModComponentDiscovery.Discover 公开:只发现、不执行生命周期 - ShrinkModLoader.LoadComposed / ShrinkModCordisRuntime.ApplyComposedAsync:宿主提供元数据组合加载,支持纯数据包与 IShrinkModWrapper 公开真实实例 - 公开 TryAttachEventBusInstance,随生命周期逆操作释放 - 依赖新增 VersionRange(Maven/Forge 区间语法)与 Ordering(Before/After) - AssemblyResolvePolicy 可限制跨模组程序集解析
This commit is contained in:
1 parent
5398036d3b
commit
d15bf00512
29 files changed
+917
-132
No files matched your search
@@ -10,9 +10,29 @@ namespace ShrinkModFramework
|
||||
/// 把工程内程序集和外部 DLL 的当前 revision 投影为延迟组件源。
|
||||
/// 同一路径的旧外部程序集无法从 Mono AppDomain 卸载,但不会再进入候选集合。
|
||||
/// </summary>
|
||||
internal static class ShrinkModComponentDiscovery
|
||||
public static class ShrinkModComponentDiscovery
|
||||
{
|
||||
public static IReadOnlyList<ShrinkModComponentSource> Discover(
|
||||
ShrinkModFrameworkSettings settings, IEnumerable<string> authorizedDllPaths) =>
|
||||
Discover(settings, settings != null && settings.verboseLogging, authorizedDllPaths);
|
||||
|
||||
/// <summary>只发现,不构造实例或提交 current revision。WithMetadata 可保留发现快照。</summary>
|
||||
public static IReadOnlyList<ShrinkModComponentSource> Discover(
|
||||
ShrinkModFrameworkSettings settings, bool verboseLogging, IEnumerable<string> authorizedDllPaths)
|
||||
{
|
||||
if (authorizedDllPaths == null) throw new ArgumentNullException(nameof(authorizedDllPaths));
|
||||
var previous = ShrinkExternalModAssemblyLoader.CaptureState();
|
||||
try
|
||||
{
|
||||
var sources = DiscoverCurrent(settings, verboseLogging, authorizedDllPaths);
|
||||
var state = ShrinkExternalModAssemblyLoader.CaptureState();
|
||||
foreach (var source in sources) source.DiscoveryState = state;
|
||||
return sources;
|
||||
}
|
||||
finally { ShrinkExternalModAssemblyLoader.RestoreState(previous); }
|
||||
}
|
||||
|
||||
internal static IReadOnlyList<ShrinkModComponentSource> DiscoverCurrent(
|
||||
ShrinkModFrameworkSettings settings,
|
||||
bool verboseLogging,
|
||||
IEnumerable<string> authorizedDllPaths)
|
||||
@@ -53,7 +73,7 @@ namespace ShrinkModFramework
|
||||
var dependencies = type
|
||||
.GetCustomAttributes<ShrinkModDependencyAttribute>(false)
|
||||
.Select(attribute => new ShrinkModDependency(
|
||||
attribute.ModId, attribute.MinimumVersion, attribute.Optional))
|
||||
attribute.ModId, attribute.MinimumVersion, attribute.Optional, attribute.Ordering, attribute.VersionRange))
|
||||
.ToArray();
|
||||
var info = new ShrinkModInfo(
|
||||
modAttribute.ModId,
|
||||
|
||||
Reference in new issue
Block a user