Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/dotnet-core-uninstall/Shared/Utils/Regexes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal static class Regexes
$@"(?<{ArchGroupName}>\-?x64|x86)");

private static readonly Regex _previewVersionSdkDisplayNameRegex = new Regex(
$@"(?<{PreviewGroupName}>\s?\-\s?((preview|alpha)\.?{_previewVersionNumberRegex.ToString()}|rc{_rcVersionNumberRegex.ToString()}))");
$@"(?<{PreviewGroupName}>.*((preview|alpha)[\.\-\s]?{_previewVersionNumberRegex.ToString()}|rc{_rcVersionNumberRegex.ToString()}))");
private static readonly Regex _previewVersionSdkCachePathRegex = new Regex(
$@"(?<{PreviewGroupName}>\-((preview|alpha)\.?{_previewVersionNumberRegex.ToString()}|rc{_rcVersionNumberRegex.ToString()}(\.\d+)?)\-(?<{BuildGroupName}>\d+))");
private static readonly Regex _previewVersionRuntimeCachePathRegex = new Regex(
Expand All @@ -41,7 +41,7 @@ internal static class Regexes
$@"(?<{PreviewGroupName}>\-(preview{_previewVersionNumberRegex.ToString()}(\.{_buildNumberRegex.ToString()}\.\d+|\-(final|{_buildNumberRegex.ToString()}(\-\d+)?))|rc{_rcVersionNumberRegex.ToString()}\-final))");

private static readonly string _sdkVersionBasicRegexFormat =
$@"(?<{VersionGroupName}>{_majorMinorRegex.ToString()}\.((?<{SdkMinorGroupName}>\d+)(?<{PatchGroupName}>\d{{{{2}}}})|(?<{PatchGroupName}>\d{{{{1,2}}}}))({{0}})?)";
$@"(?<{VersionGroupName}>{_majorMinorRegex.ToString()}\.((?<{SdkMinorGroupName}>\d+)(?<{PatchGroupName}>\d{{{{0,2}}}}))({{0}})?)";
private static readonly string _notCapturedRuntimeVersionBasicRegexFormat =
$@"{_majorMinorRegex.ToString()}\.(?<{PatchGroupName}>\d+)({{0}})?";
private static readonly string _runtimeVersionBasicRegexFormat =
Expand Down Expand Up @@ -76,7 +76,7 @@ internal static class Regexes

public static readonly Regex VersionDisplayNameRegex = new Regex(string.Format(
_sdkVersionBasicRegexFormat,
_previewVersionSdkDisplayNameRegex.ToString()));
_previewVersionSdkDisplayNameRegex.ToString()), RegexOptions.IgnoreCase);
public static readonly Regex BundleMajorMinorRegex = new Regex(
$@"^{_majorMinorRegex.ToString()}$");
public static readonly Regex BundleCachePathRegex = new Regex(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ public static Dictionary<Bundle, string> GetReasonRequiredStrings(IEnumerable<Bu
foreach (var division in bundlesByDivisions)
{
var requiredBundle = division.Key.Max();
requirementStringResults = requirementStringResults.Append((requiredBundle, division.Value));
requirementStringResults = requirementStringResults.Concat(division.Key
.Where(bundle => !bundle.Equals(requiredBundle))
.Select(bundle => (bundle, string.Empty)));
requirementStringResults = requirementStringResults.Concat([
(requiredBundle, division.Value),
..division.Key
.Where(bundle => !bundle.Equals(requiredBundle))
.Select(bundle => (bundle, string.Empty))
]);
}

return requirementStringResults
.GroupBy(pair => pair.bundle)
.Select(group => group.First()) // Remove duplicates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does ordering matter in a dictionary? I think these are real duplicates and can't have different values. Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, although potential duplicates might arise as well from unforseen cases with the regex. So just playing it safe just in case as this exception would not be handled

.OrderByDescending(pair => pair.bundle.DisplayName)
.ToDictionary(i => i.bundle, i => i.Item2);
}
Expand Down
7 changes: 4 additions & 3 deletions src/dotnet-core-uninstall/Windows/RegistryQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,13 @@ public static BundleVersion GetBundleVersion(string displayName, string uninstal
return new AspNetRuntimeVersion(versionString);
}
else if ((displayName.IndexOf(".NET Core SDK", StringComparison.OrdinalIgnoreCase) >= 0) ||
(displayName.IndexOf("Microsoft .NET SDK", StringComparison.OrdinalIgnoreCase) >= 0) ||
uninstallString.IndexOf("dotnet-dev-win") >= 0)
(displayName.IndexOf("Microsoft .NET SDK", StringComparison.OrdinalIgnoreCase) >= 0) ||
uninstallString.IndexOf("dotnet-dev-win") >= 0)
{
return new SdkVersion(versionString);
}
else if (displayName.IndexOf(".NET Core Runtime", StringComparison.OrdinalIgnoreCase) >= 0 || Regex.IsMatch(displayName, @".*\.NET Core.*Runtime") ||
else if (displayName.IndexOf(".NET Core Runtime", StringComparison.OrdinalIgnoreCase) >= 0 ||
Regex.IsMatch(displayName, @".*\.NET Core.*Runtime") ||
displayName.IndexOf(".NET Runtime", StringComparison.OrdinalIgnoreCase) >= 0)
{
return new RuntimeVersion(versionString);
Expand Down