From b6eb0dfc52722fcc78f6b333d51f111293733ef2 Mon Sep 17 00:00:00 2001 From: routersys Date: Sun, 11 Oct 2026 20:57:37 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=83=97=E3=83=AD?= =?UTF-8?q?=E3=82=B8=E3=82=A7=E3=82=AF=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HostAssemblyResolver.cs | 37 +++++++++ .../SpectrumColorShift.Tests.csproj | 77 +++++++++++++++++++ SpectrumColorShift.slnx | 1 + 3 files changed, 115 insertions(+) create mode 100644 SpectrumColorShift.Tests/HostAssemblyResolver.cs create mode 100644 SpectrumColorShift.Tests/SpectrumColorShift.Tests.csproj diff --git a/SpectrumColorShift.Tests/HostAssemblyResolver.cs b/SpectrumColorShift.Tests/HostAssemblyResolver.cs new file mode 100644 index 0000000..99bfdd4 --- /dev/null +++ b/SpectrumColorShift.Tests/HostAssemblyResolver.cs @@ -0,0 +1,37 @@ +using System.IO; +using System.Reflection; +using System.Runtime.CompilerServices; + +namespace SpectrumColorShift.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/SpectrumColorShift.Tests/SpectrumColorShift.Tests.csproj b/SpectrumColorShift.Tests/SpectrumColorShift.Tests.csproj new file mode 100644 index 0000000..f2f4740 --- /dev/null +++ b/SpectrumColorShift.Tests/SpectrumColorShift.Tests.csproj @@ -0,0 +1,77 @@ + + + + net10.0-windows10.0.19041.0 + true + enable + enable + false + SpectrumColorShift.Tests + SpectrumColorShift.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.Direct3D11.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/SpectrumColorShift.slnx b/SpectrumColorShift.slnx index 8852787..34b22e5 100644 --- a/SpectrumColorShift.slnx +++ b/SpectrumColorShift.slnx @@ -9,6 +9,7 @@ +