- ShrinkModComponentDiscovery.Discover 公开:只发现、不执行生命周期 - ShrinkModLoader.LoadComposed / ShrinkModCordisRuntime.ApplyComposedAsync:宿主提供元数据组合加载,支持纯数据包与 IShrinkModWrapper 公开真实实例 - 公开 TryAttachEventBusInstance,随生命周期逆操作释放 - 依赖新增 VersionRange(Maven/Forge 区间语法)与 Ordering(Before/After) - AssemblyResolvePolicy 可限制跨模组程序集解析
56 lines
2.0 KiB
C#
56 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
using NUnit.Framework;
|
|
using UnityEngine;
|
|
|
|
namespace UnityEditor.PackageManager
|
|
{
|
|
public class PackageInfo
|
|
{
|
|
public string resolvedPath;
|
|
public static PackageInfo FindForAssembly(System.Reflection.Assembly assembly)
|
|
{
|
|
var directory = new DirectoryInfo(AppContext.BaseDirectory);
|
|
while (directory != null && !File.Exists(Path.Combine(directory.FullName, "package.json"))) directory = directory.Parent;
|
|
return new PackageInfo { resolvedPath = directory?.FullName ?? throw new DirectoryNotFoundException("Package root") };
|
|
}
|
|
}
|
|
}
|
|
namespace UnityEditor
|
|
{
|
|
public static class AssetDatabase
|
|
{
|
|
public static string[] FindAssets(string query) => Array.Empty<string>();
|
|
public static string GUIDToAssetPath(string guid) => guid;
|
|
}
|
|
}
|
|
namespace UnityEngine.TestTools
|
|
{
|
|
public static class LogAssert
|
|
{
|
|
internal static readonly Queue<(LogType type, Regex text)> Expected = new();
|
|
public static void Expect(LogType type, Regex text) => Expected.Enqueue((type, text));
|
|
public static void Expect(LogType type, string text) => Expect(type, new Regex(Regex.Escape(text)));
|
|
}
|
|
}
|
|
[SetUpFixture]
|
|
public class LogVerification
|
|
{
|
|
private readonly List<string> _unexpected = new();
|
|
[OneTimeSetUp] public void Start() => Debug.Logged += Observe;
|
|
private void Observe(LogType type, string text)
|
|
{
|
|
var expected = UnityEngine.TestTools.LogAssert.Expected;
|
|
if (expected.Count > 0 && expected.Peek().type == type && expected.Peek().text.IsMatch(text)) expected.Dequeue();
|
|
else if (type == LogType.Error || type == LogType.Exception) _unexpected.Add(text);
|
|
}
|
|
[OneTimeTearDown] public void Finish()
|
|
{
|
|
Debug.Logged -= Observe;
|
|
Assert.IsEmpty(_unexpected, "Unexpected Unity-style errors");
|
|
Assert.IsEmpty(UnityEngine.TestTools.LogAssert.Expected, "Expected log was not emitted");
|
|
}
|
|
}
|