diff --git a/CKAN/CKAN/Registry/Registry.cs b/CKAN/CKAN/Registry/Registry.cs index 4c8f84e966..9dcf8b50e7 100644 --- a/CKAN/CKAN/Registry/Registry.cs +++ b/CKAN/CKAN/Registry/Registry.cs @@ -404,7 +404,7 @@ public List Incompatible(KSPVersion ksp_version) if (available == null) { - incompatible.Add(LatestAvailable(candidate)); + incompatible.Add(LatestAvailable(candidate, null)); } } @@ -422,7 +422,7 @@ public List Incompatible(KSPVersion ksp_version) // TODO: Consider making this internal, because practically everything should // be calling LatestAvailableWithProvides() - public CkanModule LatestAvailable(string module, KSPVersion ksp_version = null) + public CkanModule LatestAvailable(string module, KSPVersion ksp_version) { log.DebugFormat("Finding latest available for {0}", module); diff --git a/CKAN/GUI/GUIMod.cs b/CKAN/GUI/GUIMod.cs index 7bf38fd73b..09a914e124 100644 --- a/CKAN/GUI/GUIMod.cs +++ b/CKAN/GUI/GUIMod.cs @@ -34,7 +34,7 @@ public GUIMod(CkanModule mod, Registry registry, KSPVersion current_ksp_version) Authors = mod.author == null ? "N/A" : String.Join(",", mod.author); var installedVersion = registry.InstalledVersion(mod.identifier); - var latestVersion = registry.LatestAvailable(mod.identifier); + var latestVersion = registry.LatestAvailable(mod.identifier, current_ksp_version); var kspVersion = mod.ksp_version; InstalledVersion = installedVersion != null ? installedVersion.ToString() : "-"; diff --git a/CKAN/GUI/MainInstall.cs b/CKAN/GUI/MainInstall.cs index f84869fb91..1551764f21 100644 --- a/CKAN/GUI/MainInstall.cs +++ b/CKAN/GUI/MainInstall.cs @@ -500,7 +500,7 @@ private void UpdateRecommendedDialog(Dictionary> mods, bool try { - module = RegistryManager.Instance(manager.CurrentInstance).registry.LatestAvailable(pair.Key); + module = RegistryManager.Instance(manager.CurrentInstance).registry.LatestAvailable(pair.Key, CurrentInstance.Version()); } catch { diff --git a/CKAN/GUI/MainModList.cs b/CKAN/GUI/MainModList.cs index 4580c0d66f..71d161ea67 100644 --- a/CKAN/GUI/MainModList.cs +++ b/CKAN/GUI/MainModList.cs @@ -202,7 +202,7 @@ public List> ComputeChangeSetFromModL foreach (var reverseDependencies in modulesToRemove.Select(mod => installer.FindReverseDependencies(mod))) { //TODO This would be a good place to have a event that alters the row's graphics to show it will be removed - var modules = reverseDependencies.Select(rDep => registry.LatestAvailable(rDep)); + var modules = reverseDependencies.Select(rDep => registry.LatestAvailable(rDep, current_instance.Version())); changeset.UnionWith( modules.Select(mod => new KeyValuePair(mod, GUIModChangeType.Remove))); } diff --git a/CKAN/Tests/CKAN/Registry/Registry.cs b/CKAN/Tests/CKAN/Registry/Registry.cs index 363c866e34..093f4bcda1 100644 --- a/CKAN/Tests/CKAN/Registry/Registry.cs +++ b/CKAN/Tests/CKAN/Registry/Registry.cs @@ -100,10 +100,10 @@ public void TxEmbeddedCommit() { reg = CKAN.Registry.Empty(); reg.AddAvailable(module); - Assert.AreEqual(identifier, reg.LatestAvailable(identifier).identifier); + Assert.AreEqual(identifier, reg.LatestAvailable(identifier, null).identifier); scope.Complete(); } - Assert.AreEqual(identifier, reg.LatestAvailable(identifier).identifier); + Assert.AreEqual(identifier, reg.LatestAvailable(identifier, null).identifier); } [Test] @@ -114,11 +114,11 @@ public void TxCommit() using (var scope = new TransactionScope()) { registry.AddAvailable(module); - Assert.AreEqual(module.identifier, registry.LatestAvailable(identifier).identifier); + Assert.AreEqual(module.identifier, registry.LatestAvailable(identifier, null).identifier); scope.Complete(); } - Assert.AreEqual(module.identifier, registry.LatestAvailable(identifier).identifier); + Assert.AreEqual(module.identifier, registry.LatestAvailable(identifier, null).identifier); } [Test] @@ -129,14 +129,14 @@ public void TxRollback() using (var scope = new TransactionScope()) { registry.AddAvailable(module); - Assert.AreEqual(module.identifier, registry.LatestAvailable(identifier).identifier); + Assert.AreEqual(module.identifier, registry.LatestAvailable(identifier,null).identifier); scope.Dispose(); // Rollback, our module should no longer be available. } Assert.Throws(delegate { - registry.LatestAvailable(identifier); + registry.LatestAvailable(identifier,null); }); } diff --git a/CKAN/Tests/CKAN/Relationships/SanityChecker.cs b/CKAN/Tests/CKAN/Relationships/SanityChecker.cs index 6c736f6570..f102cf0ea9 100644 --- a/CKAN/Tests/CKAN/Relationships/SanityChecker.cs +++ b/CKAN/Tests/CKAN/Relationships/SanityChecker.cs @@ -39,7 +39,7 @@ public void Void() public void DogeCoin() { // Test with a module that depends and conflicts with nothing. - var mods = new List {registry.LatestAvailable("DogeCoinFlag")}; + var mods = new List {registry.LatestAvailable("DogeCoinFlag",null)}; Assert.IsTrue(CKAN.SanityChecker.IsConsistent(mods), "DogeCoinFlag"); } @@ -49,13 +49,13 @@ public void CustomBiomes() { var mods = new List(); - mods.Add(registry.LatestAvailable("CustomBiomes")); + mods.Add(registry.LatestAvailable("CustomBiomes",null)); Assert.IsFalse(CKAN.SanityChecker.IsConsistent(mods), "CustomBiomes without data"); - mods.Add(registry.LatestAvailable("CustomBiomesKerbal")); + mods.Add(registry.LatestAvailable("CustomBiomesKerbal",null)); Assert.IsTrue(CKAN.SanityChecker.IsConsistent(mods), "CustomBiomes with stock data"); - mods.Add(registry.LatestAvailable("CustomBiomesRSS")); + mods.Add(registry.LatestAvailable("CustomBiomesRSS",null)); Assert.IsFalse(CKAN.SanityChecker.IsConsistent(mods), "CustomBiomes with conflicting data"); } @@ -70,17 +70,17 @@ public void CustomBiomesWithDlls() // This would actually be a terrible thing for users to have, but it tests the // relationship we want. - mods.Add(registry.LatestAvailable("CustomBiomesKerbal")); + mods.Add(registry.LatestAvailable("CustomBiomesKerbal",null)); Assert.IsTrue(CKAN.SanityChecker.IsConsistent(mods, dlls), "CustomBiomes DLL, with config added"); - mods.Add(registry.LatestAvailable("CustomBiomesRSS")); + mods.Add(registry.LatestAvailable("CustomBiomesRSS",null)); Assert.IsFalse(CKAN.SanityChecker.IsConsistent(mods, dlls), "CustomBiomes with conflicting data"); } [Test] public void ConflictWithDll() { - var mods = new List { registry.LatestAvailable("SRL") }; + var mods = new List { registry.LatestAvailable("SRL",null) }; var dlls = new List { "QuickRevert" }; Assert.IsTrue(CKAN.SanityChecker.IsConsistent(mods), "SRL can be installed by itself"); @@ -92,9 +92,9 @@ public void ModulesToProvides() { var mods = new List { - registry.LatestAvailable("CustomBiomes"), - registry.LatestAvailable("CustomBiomesKerbal"), - registry.LatestAvailable("DogeCoinFlag") + registry.LatestAvailable("CustomBiomes",null), + registry.LatestAvailable("CustomBiomesKerbal",null), + registry.LatestAvailable("DogeCoinFlag",null) }; var provides = CKAN.SanityChecker.ModulesToProvides(mods); @@ -112,13 +112,13 @@ public void FindUnmetDependencies() var dlls = new List(); Assert.IsEmpty(CKAN.SanityChecker.FindUnmetDependencies(mods, dlls), "Empty list"); - mods.Add(registry.LatestAvailable("DogeCoinFlag")); + mods.Add(registry.LatestAvailable("DogeCoinFlag",null)); Assert.IsEmpty(CKAN.SanityChecker.FindUnmetDependencies(mods, dlls), "DogeCoinFlag"); - mods.Add(registry.LatestAvailable("CustomBiomes")); + mods.Add(registry.LatestAvailable("CustomBiomes",null)); Assert.Contains("CustomBiomesData", CKAN.SanityChecker.FindUnmetDependencies(mods, dlls).Keys, "Missing CustomBiomesData"); - mods.Add(registry.LatestAvailable("CustomBiomesKerbal")); + mods.Add(registry.LatestAvailable("CustomBiomesKerbal",null)); Assert.IsEmpty(CKAN.SanityChecker.FindUnmetDependencies(mods, dlls), "CBD+CBK"); mods.RemoveAll(x => x.identifier == "CustomBiomes"); @@ -132,14 +132,14 @@ public void ReverseDepends() { var mods = new List { - registry.LatestAvailable("CustomBiomes"), - registry.LatestAvailable("CustomBiomesKerbal"), - registry.LatestAvailable("DogeCoinFlag") + registry.LatestAvailable("CustomBiomes",null), + registry.LatestAvailable("CustomBiomesKerbal",null), + registry.LatestAvailable("DogeCoinFlag",null) }; // Make sure some of our expectations regarding dependencies are correct. - Assert.Contains("CustomBiomes", registry.LatestAvailable("CustomBiomesKerbal").depends.Select(x => x.name).ToList()); - Assert.Contains("CustomBiomesData", registry.LatestAvailable("CustomBiomes").depends.Select(x => x.name).ToList()); + Assert.Contains("CustomBiomes", registry.LatestAvailable("CustomBiomesKerbal",null).depends.Select(x => x.name).ToList()); + Assert.Contains("CustomBiomesData", registry.LatestAvailable("CustomBiomes",null).depends.Select(x => x.name).ToList()); // Removing DCF should only remove itself. var to_remove = new List();