diff --git a/Core/Registry/CompatibilitySorter.cs b/Core/Registry/CompatibilitySorter.cs
index d779cfad3..935bb62ad 100644
--- a/Core/Registry/CompatibilitySorter.cs
+++ b/Core/Registry/CompatibilitySorter.cs
@@ -26,8 +26,8 @@ public class CompatibilitySorter
/// Collection of installed DLCs
public CompatibilitySorter(GameVersionCriteria crit,
IEnumerable> available,
- Dictionary> providers,
- Dictionary installed,
+ IDictionary> providers,
+ IDictionary installed,
ICollection dlls,
IDictionary dlc)
{
@@ -103,9 +103,9 @@ public ICollection LatestIncompatible
}
}
- private readonly Dictionary installed;
- private readonly ICollection dlls;
- private readonly IDictionary dlc;
+ private readonly IDictionary installed;
+ private readonly ICollection dlls;
+ private readonly IDictionary dlc;
private List? latestCompatible;
private List? latestIncompatible;
@@ -119,8 +119,8 @@ public ICollection LatestIncompatible
/// Mapping from identifiers to compatible mods providing those identifiers
///
private static Dictionary> CompatibleProviders(
- GameVersionCriteria crit,
- Dictionary> providers)
+ GameVersionCriteria crit,
+ IDictionary> providers)
=> providers
.AsParallel()
.Select(kvp => new KeyValuePair>(
diff --git a/Core/Registry/Registry.cs b/Core/Registry/Registry.cs
index 3086a4ca3..bec1acdcf 100644
--- a/Core/Registry/Registry.cs
+++ b/Core/Registry/Registry.cs
@@ -42,11 +42,11 @@ public class Registry : IEnlistmentNotification, IRegistryQuerier
[JsonProperty]
[JsonConverter(typeof(JsonParallelDictionaryConverter))]
- private readonly Dictionary installed_modules;
+ private readonly IDictionary installed_modules;
// filename (case insensitive on Windows) => module
[JsonProperty]
- private Dictionary installed_files;
+ private IDictionary installed_files;
///
/// Returns all the activated registries.
@@ -55,9 +55,8 @@ public class Registry : IEnlistmentNotification, IRegistryQuerier
///
[JsonIgnore]
public ReadOnlyDictionary Repositories
- => repositories is not null
- ? new ReadOnlyDictionary(repositories)
- : new ReadOnlyDictionary(new Dictionary());
+ => new ReadOnlyDictionary(repositories
+ ?? new SortedDictionary());
///
/// Wrapper around assignment to this.repositories that invalidates
@@ -342,9 +341,9 @@ private Registry(RepositoryDataManager? repoData)
}
public Registry(RepositoryDataManager? repoData,
- Dictionary installed_modules,
+ IDictionary installed_modules,
Dictionary installed_dlls,
- Dictionary installed_files,
+ IDictionary installed_files,
SortedDictionary repositories)
: this(repoData)
{
@@ -857,8 +856,9 @@ public void RegisterModule(CkanModule mod,
installed_files[file] = mod.identifier;
}
- // Make sure mod-owned files aren't in the manually installed DLL dict
- installed_dlls.RemoveWhere(kvp => relativeFiles.Contains(kvp.Value));
+ // Make sure this mod and its files aren't in the manually installed DLL dict
+ installed_dlls.RemoveWhere(kvp => kvp.Key == mod.identifier
+ || relativeFiles.Contains(kvp.Value));
// Finally register our module proper
installed_modules.Add(mod.identifier,
@@ -916,9 +916,12 @@ public void DeregisterModule(GameInstance inst, string identifier)
/// Does nothing if we already have this data.
///
/// Mapping from identifier to relative path
- public bool SetDlls(Dictionary dlls)
+ public bool SetDlls(IDictionary dlls)
{
- var unregistered = dlls.Where(kvp => !installed_files.ContainsKey(kvp.Value))
+ var instIdents = InstalledModules.Select(im => im.identifier)
+ .ToHashSet();
+ var unregistered = dlls.Where(kvp => !instIdents.Contains(kvp.Key)
+ && !installed_files.ContainsKey(kvp.Value))
.ToDictionary();
if (!unregistered.DictionaryEquals(installed_dlls))
{
@@ -930,7 +933,7 @@ public bool SetDlls(Dictionary dlls)
return false;
}
- public bool SetDlcs(Dictionary dlcs)
+ public bool SetDlcs(IDictionary dlcs)
{
var installed = InstalledDlc;
if (!dlcs.DictionaryEquals(installed))