Remove date comparison from SelectInstanceCommand · microsoft/vssetup.powershell@cfd1a1e (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Commit cfd1a1e
authored and
committed
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.
File tree
1 file changed
lines changed
- src/VSSetup.PowerShell/PowerShell
1 file changed
lines changed
Lines changed: 1 addition & 4 deletions
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -149,10 +149,7 @@ bool Contains(IEnumerable packages, Func<PackageReference, str | ||
149 | 149 | { |
150 | 150 | if (Latest) |
151 | 151 | { |
152 | -if (latestInstance == null | | |
153 | -{ | |
154 | -latestInstance = instance; | |
155 | -} | |
152 | +latestInstance = instance; | |
156 | 153 | } |
157 | 154 | else |
158 | 155 | { |