-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Support trailing commas and comments in .slnf files #51962
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
Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
|
@copilot please replace the two new net8.0 target frameworks you added with |
|
Tested in codespaces with a slnf that had trailing commas and comments. |
…date copilot instructions Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Done in 5fac8cb. Replaced both instances of |
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 adds support for trailing commas and JSON comments in solution filter (.slnf) files, aligning the SDK's behavior with MSBuild's support added in dotnet/msbuild#6346. The change modifies the JSON parsing in SlnFileFactory.CreateFromFilteredSolutionFile to allow these relaxed JSON features, improving developer experience when editing .slnf files.
Key Changes
- Modified
SlnFileFactory.csto passJsonDocumentOptionswithAllowTrailingCommas = trueandCommentHandling = JsonCommentHandling.Skipwhen parsing .slnf files - Added comprehensive test coverage with two new test cases validating both trailing commas and comments work correctly
- Created
TestAppWithTrailingCommaSlnftest asset with two .slnf files demonstrating both features
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Cli/dotnet/SlnFileFactory.cs | Configured JsonDocumentOptions to allow trailing commas and skip comments when parsing .slnf files |
| test/dotnet.Tests/CommandTests/Solution/List/GivenDotnetSlnList.cs | Added two parameterized tests validating both "sln" and "solution" commands work with trailing commas and comments in .slnf files |
| test/TestAssets/TestProjects/TestAppWithTrailingCommaSlnf/AppWithTrailingComma.slnf | Test asset demonstrating .slnf with trailing comma and comments |
| test/TestAssets/TestProjects/TestAppWithTrailingCommaSlnf/AppWithComments.slnf | Test asset demonstrating .slnf with multi-line and single-line comments |
| test/TestAssets/TestProjects/TestAppWithTrailingCommaSlnf/App.sln | Base solution file referenced by the test .slnf files |
| test/TestAssets/TestProjects/TestAppWithTrailingCommaSlnf/App/App.csproj | App project referenced in the test solution |
| test/TestAssets/TestProjects/TestAppWithTrailingCommaSlnf/App/Program.cs | Simple console app for test asset |
| test/TestAssets/TestProjects/TestAppWithTrailingCommaSlnf/Lib/Lib.csproj | Library project referenced in the test solution |
| test/TestAssets/TestProjects/TestAppWithTrailingCommaSlnf/Lib/LibClass.cs | Simple library class for test asset |
net8.0with$(CurrentTargetFramework)in App.csproj and Lib.csprojOriginal prompt
CreateFromFilteredSolutionFileimplementation for trailing comma (and allowing comments) #51929✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.