Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: Prevent buildup of _handledAssemblies. Still needs more done.
Browse files Browse the repository at this point in the history
  • Loading branch information
RiotNOR committed May 15, 2023
1 parent af170cd commit aff9a63
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions RotationSolver/RotationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private class RotationLoadContext : AssemblyLoadContext
{
readonly DirectoryInfo _directory;

static readonly Dictionary<string, Assembly> _handledAssemblies;
static Dictionary<string, Assembly> _handledAssemblies;
public RotationLoadContext(DirectoryInfo directoryInfo) : base(true)
{
_directory = directoryInfo;
Expand Down Expand Up @@ -174,13 +174,28 @@ public static Assembly LoadFrom(string filePath)

var name = assembly.GetName().Name;

Assembly tempAsm = null;

foreach (var asm in _assemblyInfos)
{
if (asm.Value.Path == filePath)
{
tempAsm = asm.Key;
}
}

if (tempAsm != null)
{
_assemblyInfos.Remove(tempAsm);
}

var attr = assembly.GetCustomAttribute<AssemblyLinkAttribute>();
_assemblyInfos[assembly] = new AssemblyInfo(name, GetAuthor(filePath, name), filePath, attr?.SupportLink, attr?.HelpLink, attr?.ChangeLog, attr?.Donate);


var loaded = new LoadedAssembly();
loaded.Path = filePath;
loaded.LastModified = File.GetLastWriteTimeUtc(filePath).ToString();

var idx = LoadedCustomRotations.FindIndex(item => item.Path == loaded.Path);
if (idx != -1) LoadedCustomRotations.RemoveAt(idx);
LoadedCustomRotations.Add(loaded);
Expand Down

0 comments on commit aff9a63

Please sign in to comment.