diff --git a/ProxyForge.Tests/ProxyForge.Tests.csproj b/ProxyForge.Tests/ProxyForge.Tests.csproj new file mode 100644 index 0000000..8222158 --- /dev/null +++ b/ProxyForge.Tests/ProxyForge.Tests.csproj @@ -0,0 +1,75 @@ + + + + net10.0-windows10.0.19041.0 + true + enable + enable + false + ProxyForge.Tests + ProxyForge.Tests + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + SkipPluginDeploy=true + + + + + + + + + + $(YMM4DirPath)Newtonsoft.Json.dll + false + + + $(YMM4DirPath)SharpGen.Runtime.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/ProxyForge.Tests/Ymm4AssemblyResolver.cs b/ProxyForge.Tests/Ymm4AssemblyResolver.cs new file mode 100644 index 0000000..4ce9645 --- /dev/null +++ b/ProxyForge.Tests/Ymm4AssemblyResolver.cs @@ -0,0 +1,37 @@ +using System.IO; +using System.Reflection; +using System.Runtime.CompilerServices; + +namespace ProxyForge.Tests; + +internal static class Ymm4AssemblyResolver +{ + const string MetadataKey = "Ymm4Directory"; + 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(Ymm4AssemblyResolver).Assembly + .GetCustomAttributes() + .FirstOrDefault(attribute => string.Equals(attribute.Key, MetadataKey, StringComparison.Ordinal)) + ?.Value ?? string.Empty; +} diff --git a/ProxyForge.slnx b/ProxyForge.slnx index 3861ac8..3bb2378 100644 --- a/ProxyForge.slnx +++ b/ProxyForge.slnx @@ -1,5 +1,6 @@ +