diff --git a/src/dotnet-core-uninstall/Windows/RegistryQuery.cs b/src/dotnet-core-uninstall/Windows/RegistryQuery.cs index 100bf976..0497cd6a 100644 --- a/src/dotnet-core-uninstall/Windows/RegistryQuery.cs +++ b/src/dotnet-core-uninstall/Windows/RegistryQuery.cs @@ -165,29 +165,18 @@ private static BundleArch GetBundleArch(string displayName, string bundleCachePa archString = cachePathMatch.Groups[Regexes.ArchGroupName].Value; } - if (string.IsNullOrEmpty(archString)) - { - archString = displayName.Contains(x64String) ? - x64String : - displayName.Contains(x86String) ? x86String : 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 - }; - } + archString ??= displayName.Contains(x64String) ? x64String : + displayName.Contains(x86String) ? x86String : + displayName.Contains(arm64String) ? arm64String : null; - switch (archString) + return archString switch { - 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()