Skip to content
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

Permit comments and trailing commas in solution filter files #6346

Merged
merged 2 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ public void SolutionFilterFiltersProjects()
@"
{
""solution"": {
// I'm a comment
""path"": "".\\SimpleProject\\SimpleProject.sln"",
""projects"": [
""SimpleProject\\SimpleProject.csproj""
/* ""..\\ClassLibrary\\ClassLibrary\\ClassLibrary.csproj"", */
""SimpleProject\\SimpleProject.csproj"",
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Construction/Solution/SolutionFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ internal static string ParseSolutionFromSolutionFilter(string solutionFilterFile
{
try
{
JsonDocument text = JsonDocument.Parse(File.ReadAllText(solutionFilterFile));
JsonDocument text = JsonDocument.Parse(File.ReadAllText(solutionFilterFile), new JsonDocumentOptions() { AllowTrailingCommas = true, CommentHandling = JsonCommentHandling.Skip});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go ahead and create a variable for JsonDocumentOptions so that you can comment that it should match the VS behavior.

solution = text.RootElement.GetProperty("solution");
return FileUtilities.GetFullPath(solution.GetProperty("path").GetString(), Path.GetDirectoryName(solutionFilterFile));
}
Expand Down