private AssemblyInformation GetAssemblyInformation(string assemblyPath, out WeakReference assemblyLoadContextWeakReference)
        {
            AssemblyInformationLoadContext assemblyInformationLoadContext = this.GetAssemblyInformationLoadContext(out assemblyLoadContextWeakReference);

            Assembly assembly = assemblyInformationLoadContext.LoadFromAssemblyPath(assemblyPath);

            AssemblyInformation assemblyInformation = new()
            {
                FullName             = assembly.FullName,
                ReferencedAssemblies = assembly.GetReferencedAssemblies(),
            };

            object[] customAttributes = assembly.GetCustomAttributes(false);
            assemblyInformation.Debuggable      = customAttributes.OfType <DebuggableAttribute>().FirstOrDefault();
            assemblyInformation.TargetFramework = customAttributes.OfType <TargetFrameworkAttribute>().FirstOrDefault();

            assembly.ManifestModule.GetPEKind(out PortableExecutableKinds portableExecutableKinds, out ImageFileMachine imageFileMachine);
            assemblyInformation.PortableExecutableKinds = portableExecutableKinds;
            assemblyInformation.ImageFileMachine        = imageFileMachine;

            // This initiates the unload of the AssemblyInformationLoadContext. The actual unloading doesn't happen
            // right away, GC has to kick in later to collect all the stuff.
            assemblyInformationLoadContext.Unload();

            return(assemblyInformation);
        }
        private AssemblyName[] GetReferencedAssemblies(AssemblyName assemblyName, out WeakReference assemblyLoadContextWeakReference)
        {
            AssemblyInformationLoadContext assemblyInformationLoadContext = this.GetAssemblyInformationLoadContext(out assemblyLoadContextWeakReference);

            Assembly assembly = assemblyInformationLoadContext.LoadFromAssemblyName(assemblyName);

            AssemblyName[] referencedAssemblies = assembly.GetReferencedAssemblies();

            // This initiates the unload of the AssemblyInformationLoadContext. The actual unloading doesn't happen
            // right away, GC has to kick in later to collect all the stuff.
            assemblyInformationLoadContext.Unload();

            return(referencedAssemblies);
        }