diff --git a/UndoTree.Tests/HostAssemblyResolver.cs b/UndoTree.Tests/HostAssemblyResolver.cs new file mode 100644 index 0000000..14abf72 --- /dev/null +++ b/UndoTree.Tests/HostAssemblyResolver.cs @@ -0,0 +1,37 @@ +using System.IO; +using System.Reflection; +using System.Runtime.CompilerServices; + +namespace UndoTree.Tests; + +internal static class HostAssemblyResolver +{ + const string MetadataKey = "HostDirectory"; + const string AssemblyExtension = ".dll"; + + public static string Directory { get; } = ReadDirectory(); + + public static bool IsConfigured => Directory.Length != 0 && System.IO.Directory.Exists(Directory); + + [ModuleInitializer] + internal static void Initialize() + { + if (!IsConfigured) + return; + + AppDomain.CurrentDomain.AssemblyResolve += (_, arguments) => + { + var name = new AssemblyName(arguments.Name).Name; + if (name is null) + return null; + + var candidate = Path.Combine(Directory, name + AssemblyExtension); + return File.Exists(candidate) ? Assembly.LoadFrom(candidate) : null; + }; + } + + static string ReadDirectory() => typeof(HostAssemblyResolver).Assembly + .GetCustomAttributes() + .FirstOrDefault(attribute => string.Equals(attribute.Key, MetadataKey, StringComparison.Ordinal)) + ?.Value ?? string.Empty; +} diff --git a/UndoTree.Tests/UndoTree.Tests.csproj b/UndoTree.Tests/UndoTree.Tests.csproj new file mode 100644 index 0000000..c37ae4a --- /dev/null +++ b/UndoTree.Tests/UndoTree.Tests.csproj @@ -0,0 +1,73 @@ + + + + net10.0-windows10.0.19041.0 + true + enable + enable + false + UndoTree.Tests + UndoTree.Tests + + + + + + + + + + + + SkipPluginDeploy=true + + + + + + + + + + $(YMM4DirPath)Newtonsoft.Json.dll + false + + + $(YMM4DirPath)SharpGen.Runtime.dll + false + + + $(YMM4DirPath)SharpGen.Runtime.COM.dll + false + + + $(YMM4DirPath)Vortice.Direct2D1.dll + false + + + $(YMM4DirPath)Vortice.DirectX.dll + false + + + $(YMM4DirPath)Vortice.DXGI.dll + false + + + $(YMM4DirPath)Vortice.Mathematics.dll + false + + + $(YMM4DirPath)YukkuriMovieMaker.Controls.dll + false + + + $(YMM4DirPath)YukkuriMovieMaker.Plugin.dll + false + + + + + + + + diff --git a/UndoTree.slnx b/UndoTree.slnx index caf6859..a5192a9 100644 --- a/UndoTree.slnx +++ b/UndoTree.slnx @@ -7,6 +7,7 @@ +