-
Notifications
You must be signed in to change notification settings - Fork 703
Share more package checking code between CLI and app host #10372
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
Conversation
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 centralizes package version checking by introducing shared helpers and types, replacing separate logic in both the CLI and the hosting app.
- Added
PackageUpdateHelpers
and a sharedNuGetPackage
/NuGetPackageCli
type insrc/Shared
- Replaced
IVersionFetcher
/VersionFetcher
withIPackageFetcher
/PackageFetcher
in hosting code - Updated CLI and hosting tests to use
TestPackageFetcher
and the new shared parsing logic
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/Shared/PackageUpdateHelpers.cs | New shared parsing and version comparison utilities |
src/Aspire.Hosting/VersionChecking/PackageFetcher.cs | New host-side implementation of IPackageFetcher |
src/Aspire.Hosting/VersionChecking/VersionCheckService.cs | Switched from IVersionFetcher to IPackageFetcher & called shared helpers |
tests/Aspire.Hosting.Tests/VersionChecking/VersionCheckServiceTests.cs | Refactored tests to use TestPackageFetcher |
Comments suppressed due to low confidence (5)
src/Shared/PackageUpdateHelpers.cs:5
- Add missing using directives for System.Collections.Generic, System.Linq, and System.Threading.Tasks so that List, LINQ methods, and Task types resolve correctly.
using Semver;
src/Shared/PackageUpdateHelpers.cs:113
- The empty collection literal
[]
cannot be converted to List. Replace withreturn new List<NuGetPackage>();
.
return [];
src/Aspire.Hosting/VersionChecking/PackageFetcher.cs:54
- The empty collection literal
[]
here should be a new List(), e.g.,return new List<NuGetPackage>();
.
return [];
tests/Aspire.Hosting.Tests/VersionChecking/VersionCheckServiceTests.cs:32
- You need to pass a List to the TaskCompletionSource. Use
new List<NuGetPackage> { new NuGetPackage { ... } }
instead of the array literal.
packagesTcs.TrySetResult([new NuGetPackage { Id = PackageFetcher.PackageId, Version = "100.0.0" }]);
tests/Aspire.Hosting.Tests/VersionChecking/VersionCheckServiceTests.cs:228
- Replace
Task.FromResult<List<NuGetPackage>>([])
withTask.FromResult(new List<NuGetPackage>())
to return an empty list.
_versionTask = versionTask ?? Task.FromResult<List<NuGetPackage>>([]);
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.
Works well!
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.
I need to verify the CLI changes.
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.
Works!
/backport to release/9.4 |
Started backporting to release/9.4: https://github.com/dotnet/aspire/actions/runs/16267295935 |
Description
Share and reuse CLI version checking logic with app host.
Note that there are issues sharing internal types between CLI and app host because CLI tests references both and gets duplicate type errors. Fixed by customizing a type name between projects.
Checklist
<remarks />
and<code />
elements on your triple slash comments?doc-idea
templatebreaking-change
templatediagnostic
template