Skip to content

Commit 5557f47

Browse files
Forgindgithub-actions
authored andcommitted
Cleaner comparison
1 parent 77d8962 commit 5557f47

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ internal static int VersionCompare(string first, string second)
2828
return comparison;
2929
}
3030

31-
var modifiedFirst = "1.1.1" + (firstDash == first.Length ? string.Empty : first.Substring(firstDash));
32-
var modifiedSecond = "1.1.1" + (secondDash == second.Length ? string.Empty : second.Substring(secondDash));
31+
var modifiedFirst = new ReleaseVersion(1, 1, 1, firstDash == first.Length ? string.Empty : first.Substring(firstDash));
32+
var modifiedSecond = new ReleaseVersion(1, 1, 1, secondDash == second.Length ? string.Empty : second.Substring(secondDash));
3333

34-
return new ReleaseVersion(modifiedFirst).CompareTo(new ReleaseVersion(modifiedSecond));
34+
return modifiedFirst.CompareTo(modifiedSecond);
3535
}
3636
}
3737
}

src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ private static int VersionCompare(string first, string second)
230230
return comparison;
231231
}
232232

233-
var modifiedFirst = "1.1.1" + (firstDash == first.Length ? string.Empty : first.Substring(firstDash));
234-
var modifiedSecond = "1.1.1" + (secondDash == second.Length ? string.Empty : second.Substring(secondDash));
233+
var modifiedFirst = new ReleaseVersion(1, 1, 1, firstDash == first.Length ? string.Empty : first.Substring(firstDash));
234+
var modifiedSecond = new ReleaseVersion(1, 1, 1, secondDash == second.Length ? string.Empty : second.Substring(secondDash));
235235

236-
return new ReleaseVersion(modifiedFirst).CompareTo(new ReleaseVersion(modifiedSecond));
236+
return modifiedFirst.CompareTo(modifiedSecond);
237237
}
238238

239239
void ThrowExceptionIfManifestsNotAvailable()

0 commit comments

Comments
 (0)