handle errant whitespace in global.json#15086
Merged
Merged
Conversation
1 task
1a8e61b to
ec4427e
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the NuGet updater’s PowerShell logic for reading global.json so SDK version discovery is resilient to leading whitespace/newlines, and adds regression test scenarios to validate the behavior.
Changes:
- Read
global.jsonusingGet-Content -RawbeforeConvertFrom-Jsonto avoid line-by-line parsing edge cases. - Add a new
Test-GlobalJsonVersionsscenario covering leading newline/whitespace (and a leading comment case). - Add new
global.jsonfixtures undernuget/updater/test-data/global-json-whitespace/.
Show a summary per file
| File | Description |
|---|---|
| nuget/updater/common.ps1 | Switches global.json reading to Get-Content -Raw before JSON conversion. |
| nuget/updater/test.ps1 | Adds a regression test case for global.json files with leading whitespace/newlines. |
| nuget/updater/test-data/global-json-whitespace/leading-whitespace/global.json | Fixture: global.json starting with indentation before {. |
| nuget/updater/test-data/global-json-whitespace/leading-newline/global.json | Fixture: global.json starting with a blank line. |
| nuget/updater/test-data/global-json-whitespace/leading-comment/global.json | Fixture: global.json starting with a // comment line. |
Copilot's findings
- Files reviewed: 5/5 changed files
- Comments generated: 0
ryanbrandenburg
approved these changes
May 20, 2026
ec4427e to
40d2a26
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.
The JSON parser in PowerShell doesn't like leading newline characters which makes handling
global.jsonfiles difficult. This PR forces the file to be read as a single string with-Rawwhich enablesConvertFrom-Jsonto work.