From 128fe50dbfcf5c2f7b1c55e880e0fbef601972a1 Mon Sep 17 00:00:00 2001 From: Marc Paine Date: Mon, 7 Oct 2024 16:55:50 -0700 Subject: [PATCH] Increase the upper limit to allow for .net 9 uninstall --- .../VisualStudioSafeVersionsExtractor.cs | 5 +++-- .../Commands/CommandBundleFilterTests.cs | 8 ++++---- .../Shared/VSVersioning/VSVersionTests.cs | 20 ++++++++++--------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/dotnet-core-uninstall/Shared/VSVersioning/VisualStudioSafeVersionsExtractor.cs b/src/dotnet-core-uninstall/Shared/VSVersioning/VisualStudioSafeVersionsExtractor.cs index 5200f043..93258110 100644 --- a/src/dotnet-core-uninstall/Shared/VSVersioning/VisualStudioSafeVersionsExtractor.cs +++ b/src/dotnet-core-uninstall/Shared/VSVersioning/VisualStudioSafeVersionsExtractor.cs @@ -13,7 +13,7 @@ namespace Microsoft.DotNet.Tools.Uninstall.Shared.VSVersioning internal static class VisualStudioSafeVersionsExtractor { // The tool should not be used to uninstall any more recent versions of the sdk - public static readonly SemanticVersion UpperLimit = new SemanticVersion(9, 0, 0); + public static readonly SemanticVersion UpperLimit = new SemanticVersion(10, 0, 0); // Must keep one of each of these divisions to ensure Visual Studio works. // Pairs are [inclusive, exclusive) @@ -29,7 +29,8 @@ internal static class VisualStudioSafeVersionsExtractor { (new SemanticVersion(5, 0, 100), new SemanticVersion(5, 0, 600)), string.Format(LocalizableStrings.WindowsRequirementExplanationString, " 2019") }, { (new SemanticVersion(6, 0, 100), new SemanticVersion(6, 0, 500)), string.Format(LocalizableStrings.WindowsRequirementExplanationString, " 2022") }, { (new SemanticVersion(7, 0, 100), new SemanticVersion(7, 0, 500)), string.Format(LocalizableStrings.WindowsRequirementExplanationString, " 2022") }, - { (new SemanticVersion(8, 0, 100), UpperLimit), string.Format(LocalizableStrings.WindowsRequirementExplanationString, "") } + { (new SemanticVersion(8, 0, 100), new SemanticVersion(8, 0, 500)), string.Format(LocalizableStrings.WindowsRequirementExplanationString, " 2022") }, + { (new SemanticVersion(9, 0, 100), UpperLimit), string.Format(LocalizableStrings.WindowsRequirementExplanationString, "") } }; private static (IDictionary, string>, IEnumerable) ApplyWindowsVersionDivisions(IEnumerable bundleList) diff --git a/test/dotnet-core-uninstall.Tests/Shared/Commands/CommandBundleFilterTests.cs b/test/dotnet-core-uninstall.Tests/Shared/Commands/CommandBundleFilterTests.cs index 0038ad24..0120b9be 100644 --- a/test/dotnet-core-uninstall.Tests/Shared/Commands/CommandBundleFilterTests.cs +++ b/test/dotnet-core-uninstall.Tests/Shared/Commands/CommandBundleFilterTests.cs @@ -20,7 +20,7 @@ namespace Microsoft.DotNet.Tools.Uninstall.Tests.Shared.Commands { public class CommandBundleFilterTests { - private static readonly string[] versions = { "1.0.0", "1.0.1", "1.1.0", "2.1.0", "2.1.500", "2.1.600", "2.2.100", "2.2.200", "5.0.100", "6.0.100", "7.0.100", "8.0.100", "9.0.100", "10.10.10" }; + private static readonly string[] versions = { "1.0.0", "1.0.1", "1.1.0", "2.1.0", "2.1.500", "2.1.600", "2.2.100", "2.2.200", "5.0.100", "6.0.100", "7.0.100", "8.0.100", "9.0.100", "10.0.100", "11.11.11" }; private Dictionary versionsWithArch = new Dictionary { { "3.0.0", BundleArch.X64 }, @@ -131,10 +131,10 @@ internal void TestRequiredUninstallableWhenExplicitlyAdded(IEnumerable b } [Theory] - [InlineData("remove {0} 9.0.100")] - [InlineData("remove {0} 10.10.10")] + [InlineData("remove {0} 10.0.100")] + [InlineData("remove {0} 11.11.11")] [InlineData("remove {0} --all --force")] - [InlineData("remove {0} 1.0.0 1.0.1 1.1.0 2.1.0 2.1.500 2.1.600 2.2.100 2.2.200 5.0.100 7.0.100 10.10.10")] + [InlineData("remove {0} 1.0.0 1.0.1 1.1.0 2.1.0 2.1.500 2.1.600 2.2.100 2.2.200 5.0.100 7.0.100 11.11.11")] internal void TestUpperLimitAlwaysRequired(string command) { var sdkBundles = new List>(); diff --git a/test/dotnet-core-uninstall.Tests/Shared/VSVersioning/VSVersionTests.cs b/test/dotnet-core-uninstall.Tests/Shared/VSVersioning/VSVersionTests.cs index 71ece559..c0f8c146 100644 --- a/test/dotnet-core-uninstall.Tests/Shared/VSVersioning/VSVersionTests.cs +++ b/test/dotnet-core-uninstall.Tests/Shared/VSVersioning/VSVersionTests.cs @@ -29,7 +29,8 @@ public class VSVersionTests [InlineData(new string[] { "3.0.100", "3.1.201", "5.0.100" }, new bool[] { true, false, false })] [InlineData(new string[] { "6.0.100", "6.0.101", "7.0.100" }, new bool[] { true, false, false })] [InlineData(new string[] { "7.0.100", "7.0.101", "8.0.100" }, new bool[] { true, false, false })] - [InlineData(new string[] { "9.0.100", "9.0.101", "10.100.100" }, new bool[] { false, false, false })] + [InlineData(new string[] { "8.0.100", "8.0.101", "9.0.100" }, new bool[] { true, false, false })] + [InlineData(new string[] { "10.0.100", "10.0.101", "11.100.100" }, new bool[] { false, false, false })] internal void TestGetUninstallableWindows(string[] versions, bool[] allowed) { var bundles = new List(); @@ -52,7 +53,7 @@ internal void TestGetUninstallableWindows(string[] versions, bool[] allowed) [InlineData(new string[] { "2.1.0", "1.0.1" }, new bool[] { false, true }, new string[] { "1.0.0", "1.1.0" }, new bool[] { false, false })] [InlineData(new string[] { "3.0.0", "7.0.100" }, new bool[] { true, false }, new string[] { "1.0.0", "1.1.0", "1.0.1", "1.0.2", "1.1.3" }, new bool[] { true, true, true, false, false })] [InlineData(new string[] { "3.0.0", "5.0.100" }, new bool[] { true, false }, new string[] { "1.0.0", "1.1.0", "1.0.1", "5.0.100" }, new bool[] { true, false, false, false })] - [InlineData(new string[] { "5.0.100", "5.0.101", "10.100.100" }, new bool[] { true, false, false }, new string[] { "5.0.100", "10.0.0" }, new bool[] { false, false })] + [InlineData(new string[] { "5.0.100", "5.0.101", "11.100.100" }, new bool[] { true, false, false }, new string[] { "5.0.100", "11.0.0" }, new bool[] { false, false })] [InlineData(new string[] { "5.0.100", "6.0.100", "6.0.101" }, new bool[] { true, true, false }, new string[] { "5.0.100" }, new bool[] { false })] internal void TestGetUninstallableMac(string[] sdkVersions, bool[] sdkAllowed, string[] runtimeVersions, bool[] runtimeAllowed) { @@ -80,7 +81,8 @@ internal void TestGetUninstallableMac(string[] sdkVersions, bool[] sdkAllowed, s [InlineData(new string[] { "2.2.100", "2.2.200", "2.2.300" }, new bool[] { false, true, false })] [InlineData(new string[] { "5.0.100", "5.0.101", "10.0.1" }, new bool[] { true, false, false })] [InlineData(new string[] { "6.0.100", "7.0.100", "7.0.101" }, new bool[] { false, true, false })] - [InlineData(new string[] { "9.0.100", "9.0.101", "10.100.100" }, new bool[] { false, false, false })] + [InlineData(new string[] { "9.0.100", "9.0.101", "10.100.100" }, new bool[] { true, false, false })] + [InlineData(new string[] { "10.0.100", "10.0.101", "11.100.100" }, new bool[] { false, false, false })] internal void TestGetUninstallableNonSdkVersionsWindows(string[] versions, bool[] allowed) { var bundles = new List(); @@ -117,9 +119,9 @@ internal void TestGetUninstallableNonSdkVersions(IEnumerable bundles, bo bundles = bundles.Concat(new List { new Bundle(new AspNetRuntimeVersion("1.0.0"), new BundleArch(), string.Empty, "AspNetVersion"), - new Bundle(new AspNetRuntimeVersion("10.0.0"), new BundleArch(), string.Empty, "AspNetVersion"), + new Bundle(new AspNetRuntimeVersion("11.0.0"), new BundleArch(), string.Empty, "AspNetVersion"), new Bundle(new HostingBundleVersion("1.0.0"), new BundleArch(), string.Empty, "HostingBundleVersion"), - new Bundle(new HostingBundleVersion("10.0.0"), new BundleArch(), string.Empty, "HostingBundleVersion") + new Bundle(new HostingBundleVersion("11.0.0"), new BundleArch(), string.Empty, "HostingBundleVersion") }); var uninstallable = VisualStudioSafeVersionsExtractor.GetUninstallableBundles(bundles); @@ -203,8 +205,8 @@ internal void TestGetListCommandUninstallableStringsWindows(string[] versions, s [InlineData(new string[] { "1.0.0", "1.0.1" }, new string[] { "None", "SDK" }, new string[] { "1.0.0", "1.0.1" }, new string[] { "None", "Runtime" })] [InlineData(new string[] { "2.1.0", "1.0.1" }, new string[] { "SDK", "None" }, new string[] { "2.0.0", "1.1.0" }, new string[] { "Runtime", "Runtime" })] [InlineData(new string[] { "3.0.100", "5.0.100" }, new string[] { "None", "SDK" }, new string[] { "1.0.0", "1.1.0", "1.0.1", "1.0.2", "1.1.3" }, new string[] { "None", "None", "None", "Runtime", "Runtime" })] - [InlineData(new string[] { "3.0.100", "5.0.100" }, new string[] { "None", "SDK" }, new string[] { "1.0.0", "1.1.0", "1.0.1", "9.0.100" }, new string[] { "None", "Runtime", "Runtime", "UpperLimit" })] - [InlineData(new string[] { "5.0.100", "5.0.101", "10.100.100" }, new string[] { "None", "SDK", "UpperLimit" }, new string[] { "5.0.100", "10.0.0" }, new string[] { "Runtime", "UpperLimit" })] + [InlineData(new string[] { "3.0.100", "5.0.100" }, new string[] { "None", "SDK" }, new string[] { "1.0.0", "1.1.0", "1.0.1", "10.0.100" }, new string[] { "None", "Runtime", "Runtime", "UpperLimit" })] + [InlineData(new string[] { "5.0.100", "5.0.101", "11.100.100" }, new string[] { "None", "SDK", "UpperLimit" }, new string[] { "5.0.100", "11.0.0" }, new string[] { "Runtime", "UpperLimit" })] internal void TestGetListCommandUninstallableStringsMac(string[] sdkVersions, string[] sdkExpected, string[] runtimeVersions, string[] runtimeExpected) { sdkExpected = sdkExpected.Select(s => s.Equals("UpperLimit") ? VisualStudioSafeVersionsExtractor.UpperLimit.ToNormalizedString() : s).ToArray(); @@ -228,9 +230,9 @@ internal void TestGetListCommandUninstallableStrings(IEnumerable bundles bundles = bundles.Concat(new List { new Bundle(new AspNetRuntimeVersion("1.0.0"), new BundleArch(), string.Empty, "AspNetVersion"), - new Bundle(new AspNetRuntimeVersion("10.0.0"), new BundleArch(), string.Empty, "AspNetVersion"), + new Bundle(new AspNetRuntimeVersion("11.0.0"), new BundleArch(), string.Empty, "AspNetVersion"), new Bundle(new HostingBundleVersion("1.0.0"), new BundleArch(), string.Empty, "HostingBundleVersion"), - new Bundle(new HostingBundleVersion("10.0.0"), new BundleArch(), string.Empty, "HostingBundleVersion") + new Bundle(new HostingBundleVersion("11.0.0"), new BundleArch(), string.Empty, "HostingBundleVersion") }); var strings = VisualStudioSafeVersionsExtractor.GetReasonRequiredStrings(bundles);