File: StartupHook.g.cs
Project: src\src\Components\Testing\src\Microsoft.AspNetCore.Components.Testing.csproj (Microsoft.AspNetCore.Components.Testing)
// <auto-generated/>
using System;
using System.IO;
using System.Reflection;
using System.Runtime.Loader;
 
internal class StartupHook
{
    public static void Initialize()
    {
        var startupHookAssembly = Assembly.GetExecutingAssembly();
        var testBinDirectory = Path.GetDirectoryName(startupHookAssembly.Location);
 
        AssemblyLoadContext.Default.Resolving += (context, assemblyName) =>
        {
            var candidatePath = Path.Combine(testBinDirectory, assemblyName.Name + ".dll");
            if (File.Exists(candidatePath))
            {
                return context.LoadFromAssemblyPath(candidatePath);
            }
            return null;
        };
    }
}