-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix duplicate versions in dotnet workload search version
when multiple feeds contain same version
#50980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…rsions Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
dotnet workload search version
when multiple feeds contain same version
@copilot I only want to impact the results from dotnet workload search version. Changing nugetpackagedownloader is too central and may have potential side effects for other commands that also use that file. |
…fecting other commands Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
I've moved the deduplication logic from |
src/Cli/dotnet/Commands/Workload/Search/WorkloadSearchVersionsCommand.cs
Outdated
Show resolved
Hide resolved
… operator Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug where dotnet workload search version
would display duplicate versions when multiple NuGet feeds contained the same workload version. The fix implements deduplication logic directly in the WorkloadSearchVersionsCommand.GetVersions()
method.
- Deduplicates version results from multiple NuGet feeds while maintaining proper ordering
- Requests more results than needed to account for potential duplicates, then filters to unique versions
- Adds comprehensive test coverage for the duplicate version scenario
Reviewed Changes
Copilot reviewed 27 out of 87 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/Cli/dotnet/Commands/Workload/Search/WorkloadSearchVersionsCommand.cs | Implements deduplication logic and requests extra results to handle duplicates |
test/dotnet.Tests/CommandTests/Workload/Search/GivenDotnetWorkloadSearch.cs | Adds test case verifying no duplicate versions are shown |
Multiple test files | Reorganizes using statements for consistent formatting |
test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageDownloaderMock2.cs
Outdated
Show resolved
Hide resolved
Tested and reviewed. The copilot tried to run format on the files changed, got confused, and formatted the whole project. The full actual changes are in two files. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
dotnet workload search version
shows duplicates when multiple feeds contain the same versionNuGetPackageDownloader
toWorkloadSearchVersionsCommand.GetVersions()
to avoid side effects on other commandsNuGetPackageDownloader.cs
andMockNuGetPackageDownloader.cs
WorkloadSearchVersionsCommand.GetVersions()
methodresultsToRequest
calculation per code review feedbackSummary
Per feedback from @marcpopMSFT, simplified the
resultsToRequest
calculation by removing the unnecessary ternary operator. SincenumberOfWorkloadSetsToTake * 2
already evaluates to0
whennumberOfWorkloadSetsToTake
is0
, the ternary check is redundant and reduces code readability.Latest Changes:
Simplified:
src/Cli/dotnet/Commands/Workload/Search/WorkloadSearchVersionsCommand.cs
- Changed from:to:
This improves code readability without affecting functionality, as
0 * 2 = 0
.Fixes #50979
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.