From 9db005ec898b25b333fa37d1606372198caf7d97 Mon Sep 17 00:00:00 2001 From: routersys Date: Wed, 30 Sep 2026 07:35:32 +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=81=AE=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E3=82=92=E6=97=A2=E5=AD=98=E7=BE=A4=E3=81=AB=E6=8F=83=E3=81=88?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WaveOptics.Tests/HostAssemblyResolver.cs | 37 ++++++++++++++++ WaveOptics.Tests/WaveOptics.Tests.csproj | 56 ++++++++++++++++++++++-- 2 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 WaveOptics.Tests/HostAssemblyResolver.cs diff --git a/WaveOptics.Tests/HostAssemblyResolver.cs b/WaveOptics.Tests/HostAssemblyResolver.cs new file mode 100644 index 0000000..bee9811 --- /dev/null +++ b/WaveOptics.Tests/HostAssemblyResolver.cs @@ -0,0 +1,37 @@ +using System.IO; +using System.Reflection; +using System.Runtime.CompilerServices; + +namespace WaveOptics.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/WaveOptics.Tests/WaveOptics.Tests.csproj b/WaveOptics.Tests/WaveOptics.Tests.csproj index e348237..8e1adcf 100644 --- a/WaveOptics.Tests/WaveOptics.Tests.csproj +++ b/WaveOptics.Tests/WaveOptics.Tests.csproj @@ -2,6 +2,7 @@ net10.0-windows10.0.19041.0 + true enable enable false @@ -12,20 +13,69 @@ - all runtime; build; native; contentfiles; analyzers; buildtransitive + all - all runtime; build; native; contentfiles; analyzers; buildtransitive + all - + + 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 +