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

Unescape slnf original solution path #46833

Open
wants to merge 5 commits into
base: release/9.0.3xx
Choose a base branch
from

Conversation

edvilme
Copy link
Member

@edvilme edvilme commented Feb 13, 2025

Related to dotnet/msbuild#11050

If the original solution file name contains a special character such as @, it will be escaped when reading the json slnf file. Hence, it looks for the file with the incorrect path. This attempts to unescape the original solution path

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-CLI untriaged Request triage from a team member labels Feb 13, 2025
@edvilme edvilme marked this pull request as ready for review February 13, 2025 18:13
@Copilot Copilot bot review requested due to automatic review settings February 13, 2025 18:13

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 4 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • test/TestAssets/TestProjects/TestAppWithSlnxAndSolutionFoldersWithSpecialCharacters/App.slnf: Language not supported
  • test/TestAssets/TestProjects/TestAppWithSlnxAndSolutionFoldersWithSpecialCharacters/[email protected]: Language not supported
Comments suppressed due to low confidence (1)

src/Cli/dotnet/SlnFileFactory.cs:96

  • Verify if Uri.UnescapeDataString is the correct method to use for unescaping the solution path. Ensure it does not introduce any unintended side effects.
filteredSolution.Description = Uri.UnescapeDataString(originalSolutionPathAbsolute);
@edvilme edvilme requested a review from a team February 13, 2025 18:27
@edvilme edvilme requested a review from Copilot February 13, 2025 18:46

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 4 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • test/TestAssets/TestProjects/TestAppWithSlnxAndSolutionFoldersWithSpecialCharacters/App.slnf: Language not supported
  • test/TestAssets/TestProjects/TestAppWithSlnxAndSolutionFoldersWithSpecialCharacters/[email protected]: Language not supported
@@ -78,7 +78,7 @@ public static SolutionModel CreateFromFilteredSolutionFile(string filteredSoluti
try
{
JsonElement root = JsonDocument.Parse(File.ReadAllText(filteredSolutionPath)).RootElement;
originalSolutionPath = root.GetProperty("solution").GetProperty("path").GetString();
originalSolutionPath = Uri.UnescapeDataString(root.GetProperty("solution").GetProperty("path").GetString());
filteredSolutionProjectPaths = root.GetProperty("solution").GetProperty("projects").EnumerateArray().Select(p => p.GetString()).ToArray();
Copy link
Member

Choose a reason for hiding this comment

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

Should we also unescape the absolute path and project paths?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I thought about unescaping the absolute path, but that is generated by the system so I wouldn't expect it to be escaped (as it would by the json serializer), and maybe it tries to incorrectly parse certain characters. I may be completely wrong tho, would love to hear opinions on this.
For the project paths, you're right, I agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CLI untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants