When using the path "./" or ".\" to retrieve a directory, an error stating that the path is not of a legal form is thrown by the .NET implementation.
- Dominant language
- C#
- Stars
- 4.2k
- Forks
- 778
- Avg merge
- 3h 37m
- Merged PRs (30d)
- 21
Description
### What You Are Seeing?
When retrieving a directory from disk, using the following code
var directoryPath = new DirectoryPath("./"); (or new DirectoryPath(@".\"))
var directory = context.FileSystem.GetDirectory(directoryPath);
the following error is thrown:
Error: System.ArgumentException: The path is not of a legal form.
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.DirectoryInfo.Init(String path, Boolean checkHost)
at Cake.Core.IO.Directory..ctor(DirectoryPath path)
at Cake.Core.IO.FileSystem.GetDirectory(DirectoryPath path)
### What is Expected?
The retrieval of the directory from disk.
### What version of Cake are you using?
I've seen this error occur on 0.29 and 0.33
### Are you running on a 32 or 64 bit system?
We are running a 64-bit system.
### What environment are you running on? Windows? Linux? Mac?
We are running on Windows.
### Are you running on a CI Server? If so, which one?
The issue occurs both on our build server (TeamCity), as well as on our local machines.
Contributor guide
Research direction
Start with the DirectoryPath, FileSystem.GetDirectory, and Cake.Core.IO.Directory entry points shown in the stack trace, reproducing the issue on Windows with "./" and ".\\". Trace how the path reaches DirectoryInfo and add a regression test covering both forms; done means directory retrieval succeeds without the legal-form exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100