change test for file path to account for empty string#15109
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates NuGet SDK project discovery to treat an empty/whitespace package-management “special file” path the same as missing, allowing discovery to fall back to Default package management when a repo’s MSBuild properties indicate CPM/CPV but don’t provide a usable file path.
Changes:
- Switches
packageManagementFilechecks from null-only tostring.IsNullOrWhiteSpace. - Adds explanatory comments describing the incomplete-repo configuration scenario and the intended fallback behavior.
Show a summary per file
| File | Description |
|---|---|
nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs |
Treats empty/whitespace package-management file paths as missing so discovery can fall back to default package management. |
Copilot's findings
Comments suppressed due to low confidence (1)
nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs:684
- When forcing
packageManagementKindback toDefaultdue to a missing/blank management file,packageManagementFilecan remain as an empty/whitespace string. That value then gets emitted asPackageManagementSpecialFileRelativePathand can also win during merge (since it's non-null), which may reintroduce the downstream path issues you’re trying to avoid. Consider normalizing blank values tonull(e.g., setpackageManagementFile = nullwhen falling back to Default).
if (packageManagementKind != PackageManagementKind.Default && string.IsNullOrWhiteSpace(packageManagementFile))
{
logger.Warn($"Project [{projectRelativePath}] detected package management kind of {packageManagementKind} but no package management file found; forcing management kind to {PackageManagementKind.Default}.");
packageManagementKind = PackageManagementKind.Default;
}
- Files reviewed: 1/1 changed files
- Comments generated: 0
jpinz
approved these changes
May 22, 2026
brbayes-msft
approved these changes
May 22, 2026
c7fe85d to
61e09cd
Compare
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.
A review of telemetry found an error in the wild where a repo specifies that it uses Central Package Versions but then has no
Packages.propsfile. This is most likely a copy/paste error on the repo owner's part, but nevertheless a sentinel propertyUsingMicrosoftCentralPackageVersionsSdkis set totruewhich set off the process of finding the path to the expectedPackages.propsbut when pulling out the next propertyCentralPackagesFilean empty string was returned.The fix is to change the test
is not nullto!string.IsNullOrWhiteSpacesince an empty file name isn't possible and a check a few lines down will then revert back to "Default" package management so normal updates can proceed.This is such an edge case I don't even want to honor it with a test, so a detailed comment in the source will have to suffice.