Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Flow.Launcher.Core/Plugin/PluginAssemblyLoader.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Flow.Launcher.Infrastructure;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -14,14 +15,17 @@ internal class PluginAssemblyLoader : AssemblyLoadContext

private readonly AssemblyName assemblyName;

private static readonly List<Assembly> loadedAssembly;
private static readonly ConcurrentDictionary<string, byte> loadedAssembly;

static PluginAssemblyLoader()
{
loadedAssembly = new List<Assembly>(AppDomain.CurrentDomain.GetAssemblies());
var currentAssemblies = AppDomain.CurrentDomain.GetAssemblies();
loadedAssembly = new ConcurrentDictionary<string, byte>(
currentAssemblies.Select(x => new KeyValuePair<string, byte>(x.FullName, default)));

AppDomain.CurrentDomain.AssemblyLoad += (sender, args) =>
{
loadedAssembly.Add(args.LoadedAssembly);
loadedAssembly[args.LoadedAssembly.FullName] = default;
};
}

Expand Down Expand Up @@ -57,9 +61,7 @@ internal Type FromAssemblyGetTypeOfInterface(Assembly assembly, Type type)

internal bool ExistsInReferencedPackage(AssemblyName assemblyName)
{
if (loadedAssembly.Any(a => a.FullName == assemblyName.FullName))
return true;
return false;
return loadedAssembly.ContainsKey(assemblyName.FullName);
}
}
}