From 11391796614db24d043980b2a50ac7d88fa30e00 Mon Sep 17 00:00:00 2001 From: Eduardo Villalpando Mello Date: Wed, 19 Mar 2025 13:55:19 -0700 Subject: [PATCH 1/3] Detect windows arm64 architectures --- src/dotnet-core-uninstall/Windows/RegistryQuery.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dotnet-core-uninstall/Windows/RegistryQuery.cs b/src/dotnet-core-uninstall/Windows/RegistryQuery.cs index 100bf976..2dbf7000 100644 --- a/src/dotnet-core-uninstall/Windows/RegistryQuery.cs +++ b/src/dotnet-core-uninstall/Windows/RegistryQuery.cs @@ -167,9 +167,11 @@ private static BundleArch GetBundleArch(string displayName, string bundleCachePa if (string.IsNullOrEmpty(archString)) { - archString = displayName.Contains(x64String) ? - x64String : - displayName.Contains(x86String) ? x86String : string.Empty; + archString = + displayName.Contains(x64String) ? x64String : + displayName.Contains(x86String) ? x86String : + displayName.Contains(arm64String) ? arm64String : + string.Empty; archString = archString switch { From 4e90db6ea50e6ec88892a69c9fb30bd54d5f6f78 Mon Sep 17 00:00:00 2001 From: Eduardo Villalpando Mello Date: Wed, 19 Mar 2025 14:40:27 -0700 Subject: [PATCH 2/3] Simplify --- .../Windows/RegistryQuery.cs | 30 ++++--------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/src/dotnet-core-uninstall/Windows/RegistryQuery.cs b/src/dotnet-core-uninstall/Windows/RegistryQuery.cs index 2dbf7000..f1a89e4c 100644 --- a/src/dotnet-core-uninstall/Windows/RegistryQuery.cs +++ b/src/dotnet-core-uninstall/Windows/RegistryQuery.cs @@ -165,31 +165,13 @@ private static BundleArch GetBundleArch(string displayName, string bundleCachePa archString = cachePathMatch.Groups[Regexes.ArchGroupName].Value; } - if (string.IsNullOrEmpty(archString)) + return archString switch { - archString = - displayName.Contains(x64String) ? x64String : - displayName.Contains(x86String) ? x86String : - displayName.Contains(arm64String) ? arm64String : - string.Empty; - - archString = archString switch - { - string a when a.Contains(x64String) => x64String, - string b when b.Contains(x86String) => x86String, - string b when b.Contains(arm64String) => arm64String, - _ => string.Empty - }; - } - - switch (archString) - { - case x64String: return BundleArch.X64; - case x86String: return BundleArch.X86; - case arm64String: return BundleArch.Arm64; - case "": return BundleArch.X64 | BundleArch.X86; - default: throw new ArgumentException(); - } + string a when a.Contains(x64String) => BundleArch.X64, + string b when b.Contains(x86String) => BundleArch.X86, + string c when c.Contains(arm64String) => BundleArch.Arm64, + _ => BundleArch.X64 | BundleArch.X86 + }; } public IEnumerable GetSupportedBundleTypes() From 90dbdbb375e489f591d8729f25a48f1ba629b53e Mon Sep 17 00:00:00 2001 From: Eduardo Villalpando Mello Date: Thu, 20 Mar 2025 12:41:56 -0700 Subject: [PATCH 3/3] Refactored --- src/dotnet-core-uninstall/Windows/RegistryQuery.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dotnet-core-uninstall/Windows/RegistryQuery.cs b/src/dotnet-core-uninstall/Windows/RegistryQuery.cs index f1a89e4c..0497cd6a 100644 --- a/src/dotnet-core-uninstall/Windows/RegistryQuery.cs +++ b/src/dotnet-core-uninstall/Windows/RegistryQuery.cs @@ -165,6 +165,10 @@ private static BundleArch GetBundleArch(string displayName, string bundleCachePa archString = cachePathMatch.Groups[Regexes.ArchGroupName].Value; } + archString ??= displayName.Contains(x64String) ? x64String : + displayName.Contains(x86String) ? x86String : + displayName.Contains(arm64String) ? arm64String : null; + return archString switch { string a when a.Contains(x64String) => BundleArch.X64, @@ -172,6 +176,7 @@ string b when b.Contains(x86String) => BundleArch.X86, string c when c.Contains(arm64String) => BundleArch.Arm64, _ => BundleArch.X64 | BundleArch.X86 }; + } public IEnumerable GetSupportedBundleTypes()