diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c75dcf27b..6162f5b9ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ All notable changes to this project will be documented in this file. - [Multiple] Show recommendations of full changeset with opt-out (#3892 by: HebaruSan; reviewed: techman83) - [Multiple] Dutch translation and icon duplication guardrails (#3897 by: HebaruSan; reviewed: techman83) - [GUI] Shorten toolbar button labels (#3903 by: HebaruSan; reviewed: techman83) -- [Multiple] Refactor repository and available module handling (#3904, #3907, #3908 by: HebaruSan; reviewed: techman83) +- [Multiple] Refactor repository and available module handling (#3904, #3907, #3908, #3935 by: HebaruSan; reviewed: techman83) - [Multiple] Parallelize for performance, relationship resolver improvements (#3917 by: HebaruSan; reviewed: techman83) - [Multiple] Modernize administrator and Mono version checks (#3933 by: HebaruSan; reviewed: techman83) diff --git a/Core/Registry/Registry.cs b/Core/Registry/Registry.cs index 3c5e0036c4..491b16f58b 100644 --- a/Core/Registry/Registry.cs +++ b/Core/Registry/Registry.cs @@ -964,10 +964,8 @@ public bool SetDlcs(Dictionary dlcs) installed_modules.Remove(identifier); } - foreach (var kvp in dlcs) + foreach ((string identifier, ModuleVersion version) in dlcs) { - var identifier = kvp.Key; - var version = kvp.Value; // Overwrite everything in case there are version differences installed_modules[identifier] = new InstalledModule(null, @@ -980,7 +978,7 @@ public bool SetDlcs(Dictionary dlcs) null, new List() { "SQUAD" }, new List() { new License("restricted") }, - version, + version ?? new UnmanagedModuleVersion(null), null, "dlc"), Enumerable.Empty(), false); diff --git a/Core/Relationships/RelationshipResolver.cs b/Core/Relationships/RelationshipResolver.cs index d431871bab..fa31f831df 100644 --- a/Core/Relationships/RelationshipResolver.cs +++ b/Core/Relationships/RelationshipResolver.cs @@ -875,12 +875,7 @@ public override int GetHashCode() public class Installed : SelectionReason { public override CkanModule Parent - { - get - { - throw new Exception("Should never be called on Installed"); - } - } + => throw new Exception("Should never be called on Installed"); public override string ToString() => Properties.Resources.RelationshipResolverInstalledReason; @@ -889,12 +884,7 @@ public override string ToString() public class UserRequested : SelectionReason { public override CkanModule Parent - { - get - { - throw new Exception("Should never be called on UserRequested"); - } - } + => throw new Exception("Should never be called on UserRequested"); public override string ToString() => Properties.Resources.RelationshipResolverUserReason; diff --git a/Tests/Core/Net/NetAsyncModulesDownloaderTests.cs b/Tests/Core/Net/NetAsyncModulesDownloaderTests.cs index 76bcec4589..4fb630e12b 100644 --- a/Tests/Core/Net/NetAsyncModulesDownloaderTests.cs +++ b/Tests/Core/Net/NetAsyncModulesDownloaderTests.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; -using log4net; using NUnit.Framework; using Tests.Data; @@ -17,15 +16,12 @@ namespace Tests.Core.Net [TestFixture] public class NetAsyncModulesDownloaderTests { - private GameInstanceManager manager; - private RegistryManager registry_manager; - private CKAN.Registry registry; - private DisposableKSP ksp; - private IDownloader async; - private NetModuleCache cache; - private TemporaryRepositoryData repoData; - - private static readonly ILog log = LogManager.GetLogger(typeof(NetAsyncModulesDownloaderTests)); + private GameInstanceManager manager; + private RegistryManager registry_manager; + private CKAN.Registry registry; + private DisposableKSP ksp; + private NetModuleCache cache; + private TemporaryRepositoryData repoData; [SetUp] public void Setup() @@ -51,9 +47,6 @@ public void Setup() // Make sure we have a registry we can use. registry.RepositoriesSet(repos); - // Ready our downloader. - async = new NetAsyncModulesDownloader(user, manager.Cache); - // General shortcuts cache = manager.Cache; } diff --git a/Tests/Core/Registry/Registry.cs b/Tests/Core/Registry/Registry.cs index d2d3edd40c..f4fd6ce740 100644 --- a/Tests/Core/Registry/Registry.cs +++ b/Tests/Core/Registry/Registry.cs @@ -183,6 +183,19 @@ public void CompatibleModules_MH100Installed_ExcludesModulesDependingOnMH110() } } + [Test] + public void SetDLCs_NullVersion_DoesNotThrow() + { + var registry = CKAN.Registry.Empty(); + Assert.DoesNotThrow(() => + { + registry.SetDlcs(new Dictionary + { + { "MissingVersion", null }, + }); + }, "Missing readme.txt in a DLC shouldn't trigger an exception"); + } + [Test] public void CompatibleModules_PastAndFutureCompatibility_ReturnsCurrentOnly() {