Skip to content

Commit cfd1a1e

Browse files
b-higginbothamheaths
authored andcommitted
Remove date comparison from SelectInstanceCommand
The InstanceComparer that was added as part of #41 to fix #40 isn't actually able to solve the problem due to the implementation of the ProcessRecord method in SelectInstanceCommand. InstanceComparer is used to sort instances by version and then date, but when iterating over all instances, the latestInstance variable is only set when the latestInstance date is less than the date of the current instance in the loop. This completely ignores the previous OrderBy that was done using InstanceComparer. The simplest solution at this point is to always set the latestInstance variable when the Latest flag is set because the collection is already sorted in the desired order and no additional comparisons are necessary.
1 parent 3b909f2 commit cfd1a1e

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

src/VSSetup.PowerShell/PowerShell/SelectInstanceCommand.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,7 @@ bool Contains(IEnumerable<PackageReference> packages, Func<PackageReference, str
149149
{
150150
if (Latest)
151151
{
152-
if (latestInstance == null || latestInstance.InstallDate < instance.InstallDate)
153-
{
154-
latestInstance = instance;
155-
}
152+
latestInstance = instance;
156153
}
157154
else
158155
{

0 commit comments

Comments
 (0)