-
Notifications
You must be signed in to change notification settings - Fork 1.1k
sln-add: Don't add solution folders outside the scope of solution directory #48611
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: release/9.0.3xx
Are you sure you want to change the base?
sln-add: Don't add solution folders outside the scope of solution directory #48611
Conversation
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.
Though I generally look favorably upon trying to clean up code, I don't think it's positive in servicing PRs, as it makes it harder to review and can lead to unexpected errors. I found GenerateIntermediateSolutionFoldersForProjectPath particularly confusing. I'm not saying this can't go in, but I don't think it should go into 9.0.3xx as-is.
@@ -31,13 +32,21 @@ private static string GetSolutionFolderPathWithForwardSlashes(string path) | |||
return "/" + string.Join("/", PathUtility.GetPathWithDirectorySeparator(path).Split(Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries)) + "/"; | |||
} | |||
|
|||
private static bool IsSolutionFolderPathInDirectoryScope(string relativePath) | |||
{ | |||
return !string.IsNullOrEmpty(relativePath) |
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.
So for instance, if I had a path like src\Build\..\..\..\..\test\foo
...
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.
I am not sure it is entirely possible to run into this issue since relativePath
is obtained through Path.GetRelativePath
, which should return the actual resolved path.
So instead of src\Build\..\..\..\..\test\foo
, it should be ..\..\test\foo
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.
Fair enough; missed that
835d30c
to
0d20f00
Compare
I think you could potentially be more lenient with things with .. that end up still in the sln's cone, but 🤷 |
Fixes #48608
Description
When adding a project to a solution file, solution folders are automatically generated with the relative path (relative to the solution file path). When adding projects outside the scope of the solution working directory, solution folders with invalid names are created (e.g.,
..
,:
, etc).This was addressed in #46456 but didn't consider paths in different volumes.
Regression
Yes - this worked before 9.0.2xx
Testing
Adding automated tests is difficult as it involves mounting several volumes, but manual tests were performed.
Expected behavior
Current behavior