Skip to content

Commit

Permalink
Remove date comparison from SelectInstanceCommand
Browse files Browse the repository at this point in the history
The InstanceComparer that was added as part of microsoft#41 to fix microsoft#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.
  • Loading branch information
b-higginbotham authored Jun 21, 2019
1 parent 3b909f2 commit 8b1967d
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/VSSetup.PowerShell/PowerShell/SelectInstanceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ bool Contains(IEnumerable<PackageReference> packages, Func<PackageReference, str
{
if (Latest)
{
if (latestInstance == null || latestInstance.InstallDate < instance.InstallDate)
{
latestInstance = instance;
}
latestInstance = instance;
}
else
{
Expand Down

0 comments on commit 8b1967d

Please sign in to comment.