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

Use OS-native directory separators in Path.FullPath #2367

Open
jnm2 opened this Issue Nov 25, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@jnm2
Copy link
Contributor

jnm2 commented Nov 25, 2018

There are applications which do not understand the alternate directory separator; for example, #2337. There have also been multiple CLI tools I've used where I had to do .FullName.Replace('/', '\\').

Would you consider returning OS-native directory separators from Path.FullName? It will just work in all situations, and it will not stand out and look strange on Windows any longer even when it does work.
(At times, I've manually edited MSBuild logs etc so people don't ask why I'm using weird paths.)

@patriksvensson

This comment has been minimized.

Copy link
Member

patriksvensson commented Nov 26, 2018

@jnm2 I would be OK with using System.IO.Path.DirectorySeparatorChar as the separator (see https://github.com/cake-build/cake/blob/develop/src/Cake.Core/IO/Path.cs#L41), but I wonder how much work it would be and if this would bring any side effects with it. We would also need to fix tests.

Perhaps we could add an overload to FilePath and DirectoryPath to specify (non-UNC) path separators as well, for cases where you would want to use a non OS-native path separator?

public FilePath(string path, char separator) : base(path, separator) {
   ...
}

Just thinking out loud here.

@jnm2

This comment has been minimized.

Copy link
Contributor

jnm2 commented Nov 26, 2018

Sweet! If I get to this before anyone else, I'll submit a PR that keeps the APIs the same and chooses System.IO.Path.DirectorySeparatorChar. While fixing the tests, we can see what comes up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment