public void VersionSpan_OneOnly_CorrectString() { // Arrange KspVersion min = new KspVersion(1, 0, 0); KspVersion max = new KspVersion(1, 0, 0); // Act string s = KspVersionRange.VersionSpan(min, max); // Assert Assert.AreEqual("KSP 1.0.0", s); }
public void VersionSpan_FiniteRange_CorrectString() { // Arrange KspVersion min = new KspVersion(1, 0, 0); KspVersion max = new KspVersion(1, 1, 1); // Act string s = KspVersionRange.VersionSpan(min, max); // Assert Assert.AreEqual("KSP 1.0.0 - 1.1.1", s); }
public void VersionSpan_AllVersions_CorrectString() { // Arrange KspVersion min = KspVersion.Any; KspVersion max = KspVersion.Any; // Act string s = KspVersionRange.VersionSpan(min, max); // Assert Assert.AreEqual("KSP all versions", s); }
public void VersionSpan_MaxOnly_CorrectString() { // Arrange KspVersion min = KspVersion.Any; KspVersion max = new KspVersion(1, 0, 0); // Act string s = KspVersionRange.VersionSpan(min, max); // Assert Assert.AreEqual("KSP 1.0.0 and earlier", s); }
/// <summary> /// Generate a string describing the range of game versions /// compatible with the given module. /// </summary> /// <param name="identifier">Mod name to findDependencyShallow</param> /// <returns> /// String describing range of compatible game versions. /// </returns> public static string CompatibleGameVersions(this IRegistryQuerier querier, CkanModule module) { ModuleVersion minMod = null, maxMod = null; KspVersion minKsp = null, maxKsp = null; Registry.GetMinMaxVersions( new CkanModule[] { module }, out minMod, out maxMod, out minKsp, out maxKsp ); return(KspVersionRange.VersionSpan(minKsp, maxKsp)); }
/// <summary> /// Generate a string describing the range of game versions /// compatible with the given module. /// </summary> /// <param name="identifier">Mod name to findDependencyShallow</param> /// <returns> /// String describing range of compatible game versions. /// </returns> public static string CompatibleGameVersions(this IRegistryQuerier querier, string identifier) { List <CkanModule> releases = querier.AvailableByIdentifier(identifier).ToList(); if (releases != null && releases.Count > 0) { ModuleVersion minMod = null, maxMod = null; KspVersion minKsp = null, maxKsp = null; Registry.GetMinMaxVersions(releases, out minMod, out maxMod, out minKsp, out maxKsp); return(KspVersionRange.VersionSpan(minKsp, maxKsp)); } return(""); }
private void addVersionBox(int l, int t, int r, int b, Func<string> title, Func<ConsoleColor> color, bool doubleLine, List<CkanModule> releases) { AddObject(new ConsoleFrame( l, t, r, b, title, color, doubleLine )); if (releases != null && releases.Count > 0) { ModuleVersion minMod = null, maxMod = null; KspVersion minKsp = null, maxKsp = null; Registry.GetMinMaxVersions(releases, out minMod, out maxMod, out minKsp, out maxKsp); AddObject(new ConsoleLabel( l + 2, t + 1, r - 2, () => minMod == maxMod ? $"{ModuleInstaller.WithAndWithoutEpoch(minMod?.ToString() ?? "???")}" : $"{ModuleInstaller.WithAndWithoutEpoch(minMod?.ToString() ?? "???")} - {ModuleInstaller.WithAndWithoutEpoch(maxMod?.ToString() ?? "???")}", null, color )); AddObject(new ConsoleLabel( l + 2, t + 2, r - 2, () => "Compatible with:", null, () => ConsoleTheme.Current.DimLabelFg )); AddObject(new ConsoleLabel( l + 4, t + 3, r - 2, () => KspVersionRange.VersionSpan(minKsp, maxKsp), null, color )); } }
private bool VersionsNeedManualReview(Metadata metadata, out string reason) { JObject json = metadata.Json(); var minStr = json["ksp_version_min"] ?? json["ksp_version"]; var maxStr = json["ksp_version_max"] ?? json["ksp_version"]; var minVer = minStr == null ? KspVersion.Any : KspVersion.Parse((string)minStr); var maxVer = maxStr == null ? KspVersion.Any : KspVersion.Parse((string)maxStr); if (currentRelease.IntersectWith(new KspVersionRange(minVer, maxVer)) == null) { reason = $"Hard-coded game versions not compatible with current release: {KspVersionRange.VersionSpan(minVer, maxVer)}\r\nPlease check that they match the forum thread."; return(true); } else { // Compatible with latest release, no manual review needed reason = ""; return(false); } }
public void Validate(Metadata metadata) { var mod = CkanModule.FromJson(metadata.Json().ToString()); if (!mod.IsCompatibleKSP(new KspVersionCriteria(null, buildMap.KnownVersions))) { KspVersion minKsp = null, maxKsp = null; Registry.GetMinMaxVersions(new List <CkanModule>() { mod }, out _, out _, out minKsp, out maxKsp); throw new Kraken($"{metadata.Identifier} doesn't match any valid game version: {KspVersionRange.VersionSpan(minKsp, maxKsp)}"); } }