Fix Doctor suggesting a downgrade on a preview .NET SDK - #229
Merged
Merged
Conversation
When the active SDK is a preview on a higher feature band than the newest published release (e.g. 10.0.400-preview vs stable 10.0.302), Doctor warned 'Update available: 10.0.302' -- a downgrade. The preview/stable branches compared versions by string inequality and took the first available release for the major, ignoring semantic ordering. Add FindNewerAvailableSdk helper that only returns an available SDK that is semantically newer (via SdkVersion/NuGetVersion ordering) than the installed one, and use it in both branches so lower versions are never offered as updates. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
When the active .NET SDK is a preview sitting on a higher feature band than the newest published release, Doctor wrongly reported an "update" that is actually a downgrade. For example, with
10.0.400-preview.0.26322.102installed (band 400, a nightly not yet in the releases feed), Doctor showed:10.0.302(band 300, stable) is older than the installed preview, so this is a downgrade, not an update. This is what issue #206 reports ("if I am on a .net preview doctor will yell at me").What changed
The
.NET SDKcheck inDoctorService.RunDoctorAsyncpicked the "latest available" release for the major withFirstOrDefault(s => s.Major == ...)and compared it to the installed version using string inequality. Any differing string counted as an update, even a lower one.FindNewerAvailableSdk(available, installed)that returns the newest available SDK for the same major that is semantically newer than the installed one, using the existingSdkVersion.SemanticVersion/NuGetVersionordering. It returnsnullwhen nothing newer exists.Preview SDK (...)status unless a genuinely newer version is available, so a lower published release is never offered as an update.Tests
Added 5 unit tests in
DoctorPreviewSdkTests.csfor the new helper: higher-band preview vs lower published stable (no update), genuinely newer preview (returned), newer stable (returned), already latest (none), and other-major versions ignored. FullMauiSherpa.Core.TestsDoctor suite passes (14/14).Fixes: #206