This change attempts to limit the number of allocations made when evaluating
full paths. This is particularly important when Windows paths can be way over
the historical max of 260 characters. (The new max is over 32K)
We no longer kick paths in Windows that are valid, outside of paths with colons
that are not directory separators. (This has the effect of blocking alternate
data stream access- which is a legacy behavior.)
When creating directories, we still drop the trailing separator, which causes
trailing whitespace to be trimmed. This makes it particularly difficult to create
paths with trailing spaces in .NET, which is still desirable as most code has
a tough time dealing with this scenario. We'll open them fine now, which hits
the above point of not kicking valid legacy paths (paths that don't require
extended syntax).
Several simplifications to the logic were made, including moving relative segment
evaluation to shared code and calling it directly when getting directory names
rather than relying on the not-so-obvious prior behavior of GetFullPath without
"full checks".
Commit migrated from https://github.com/dotnet/corefx/commit/11b457d1186c364bdf3e7d978006eb2417e8d060
- References dotnet/corefx#2460. File.Move and FileInfo.MoveTo no longer always overwrite the destination file; added a non-concurrent validity check to MoveFile in the Unix implementation to serve as a temporary solution.
- Resolvesdotnet/corefx#2459. Reenabled Directory_CreateDirectory.DriveLetter_Unix as it's previous failures were not the fault of the method but of the system.
- Added test checks to work around the issue in dotnet/corefx#2537 until a final decision is reached for the desktop.
- Added Interop.Link to the Interop files for the (possible) implementation of File.Move
- Consolidated all of the related files that did nothing but inherit from other classes (e.g. File_GetFiles_str and File_GetFiles_str_str were consolidated into File_GetFiles)
- Removed the "partial" keyword from some test classes
- Finished overhauling all test cases that don't directly require solutions to Build System issues before being re-added (e.g. those that require networked drives or altering the current directory)
- Added some tests to increase code coverage slightly in some cases.
- All classes and files have been renamed to match the standard set by FileStream: only include parameters in the test/class name if there are overloads
- Modified the Unix behavior for distinguishing between a FileNotFoundException and a DirectoryNotFoundException to match that of Windows.
- Removed some redundant error checks that never catch
- DirectoryInfo.MoveTo(destPath) did not have checks for destinations with paths that are over MAXPATH. I added them to better match the behavior and error timing of Directory.Move(source, dest).
Commit migrated from https://github.com/dotnet/corefx/commit/481d5c645763da79145af50d123db3f4041aa05e
Start on unblocking extended syntax. Moves some shared code to PathInternal.
Start adding tests for key scenarios. Temporarily use local libraries when
testing FileSystem (until we get an updated Runtime.Extensions package).
Commit migrated from https://github.com/dotnet/corefx/commit/72429b2ba76ebecb4c422a1d5eec05daf279b05e
- Consolidated AccessTime, WriteTime, and CreationTime tests for FileInfo, File, DirectoryInfo, and Directory into one file per folder - GetSetTimes.cs
- Added some Unix tests
-Overhauled the Write/Read/Append tests for the File class and removed many duplicate tests
-Continuation of dotnet/corefx#2390
Commit migrated from https://github.com/dotnet/corefx/commit/5aebb5487de9fd481e3dd294c9d49aa25361dde2
-Updated over a dozen test files to use the modern Xunit syntax.
-Solved file-in-use concurrency issues in the altered tests. Resolvesdotnet/corefx#1313, dotnet/corefx#2227
-Tests will no longer intermittently fail.
-Slightly improved code coverage for the FileSystem files whose tests I altered (Directory, DirectoryInfo, File, FileInfo)
-Most tests altered now inherit from similar tests to consolidate the testing robustness into as few locations as possible. For example, Directory_GetFiles_str now inherits from Directory_GetFileSystemEntries_str since the tests for Directory_GetFiles_str were the exact same ones as in Directory_GetFileSystemEntries_str anyways.
-All altered tests now use the System.IO.FileSystem.Tests namespace
-Renamed the File_WriteAll_all class name/file name to File_WriteAllText.
-I tested my changes on Windows overnight to verify that there is no more intermittent test failures. I didn't have to modify all of the files listed in dotnet/corefx#2227 to get them to pass; this concerns me but I found no way to replicate the errors I was receiving before. My guess would be that the tests in the files I didn't alter (e.g. File_WriteAll and File_ReadAll) used the same names as the tests I did alter but now that the tests I altered are changed they no longer share test file names and no longer fail as a result.
Commit migrated from https://github.com/dotnet/corefx/commit/d21ce06332afe7aba0a52491187983744c10b4a4
The FileSystem's PathHelpers internal class contains some utility functions for processing paths. Some of these functions are copies of non-exposed Path members, while others are unique. A bunch of those members have Windows-specifics coded into them, which is causing problems when dealing with various special paths on Unix, for example paths that end with double dots, relative paths that begin with a space, etc.
This commit splits PathHelpers into a PathHelpers.cs, PathHelpers.Windows.cs, and PathHelpers.Unix.cs, and implements the Unix functions appropriately.
It also fixes up a variety of tests that are now failing because they were expecting the Windows behavior.
Commit migrated from https://github.com/dotnet/corefx/commit/5945d8ced21c36e091290fb92f15a5c1f4cb2274
-Added OSX checks for Case Sensitivity tests
-Fixed a bug within several Enumerable tests that was causing a test directory to be left over.
-Increased code coverage slightly for Directory.
-Added tests to ensure whitespace file names are acceptable on Unix machines and marked those tests with an ActiveIssue referencing the newly created dotnet/corefx#2205
Commit migrated from https://github.com/dotnet/corefx/commit/b86274bbc18186768156cf3534c25c4d48656a67
-Modernized the tests for GetFIleSystemEntries and GetFiles, splitting each test case into a standalone method runnable through xunit. Similar versions of these tests now inherit from each other rather than just being copy-pasted like they were previously. Moved most test cases from using hardcoded file names to instead use GetTestFileName() in FileSystemTest.cs. Tested on Linux and Windows.
-Changed the names of some files and classes to better follow the naming conventions of the other FileSystem tests.
Commit migrated from https://github.com/dotnet/corefx/commit/9e20082a9498f2f9bf79bcebe80fd1f9efc1e39b
https://github.com/dotnet/coreclr/pull/823 fixes an where '*' and '?' are treated as invalid path characters. Once that's fixed, some additional FileSystem tests that were expecting '*' and '?' to be invalid start failing on Unix. This commit fixes those tests.
The fixes are all of either two flavors: using Interop.IsWindows to only run the test on Windows, or changing the path to include characters also invalid on Unix (namely '\0'). A bit arbitrary, but I used the former when there was a comment saying that wildcards were being tested, and I used the latter when there was a comment saying that illegal characters were being tested.
Commit migrated from https://github.com/dotnet/corefx/commit/d3fb391ef0d6505bd0f2f4bb6c269c4c96c126a3
Prior to this set of changes, 110 of the FileSystem tests were failing on Linux. After this change, all allowed tests pass.
Primary product fixes:
- Using rmdir/unlink for directory/file deletion rather than using remove
- Disallowing FileStreams to be opened for directories
- Supporting copying files when only target directory (not target name) is specified
- Overhauling directory enumeration to ensure to match Win32 behaviors related to search pattern normalization, input validation, supporting re-iteration through an enumerable, outputting partial paths based on user-supplied path, using a SafeHandle to ensure resources are cleaned up
- Fixing FileSystemObject.LastWriteTime to correctly return the LastWriteTime rather than LastAccessTime
- Fixing FileAttributes.ReadOnly handling due to inappropriate caching
- Validating inputs to FileSystemObject.Attributes, and make sure that changes to attributes are visible afterwards
- Adding support for getting CreationTime if it's supported by the OS
- Marking links with FileAttributes.ReparsePoint
- Working around current runtime bug related to exception handling and finally blocks getting executed twice
Primary test fixes:
- Suppressing tests as platform-specific that dependend on Win32-isms like drive letters, alternate data streams, etc.
- Changing a bunch of '\' usage to instead use Path.DirectorySeparatorChar or Path.Combine
- Adapting to behavioral differences between Windows and Unix, e.g. whether a directory can be deleted if it's readonly, invalid path characters, max path lengths, file sharing differences, etc.
These changes should all accrue to OSX as well, but we'll need to separately do an exercise to clean this library and tests up there for anything OSX-specific.
Commit migrated from https://github.com/dotnet/corefx/commit/dd48c9dc1f0a7142a005ff1d4c162e10facda306
The FileSystem tests are a mess... including on Windows, but especially on Unix. Before the File/Directory/etc. tests got checked in, the FileSystem tests (which then were really only for FileStream and were fairly clean) could run on Unix, with 25 of the 360 tests failing due primarily to lack of support for FileShare options. Now, with ~575 tests, when run on Unix more than 300 fail, runtime assertions occur in multiple places, and worst, all of the files in your working directory end up getting deleted!
This commit has a first set of fixes, primarily involving ensuring that paths are specified appropriately, with hundreds of changes to ensure that the right path separator is used, that particular roots aren't assumed, etc. After this commit, on Unix we're down from > 300 failures to 114 failures, and the suite is able to finish running without deleting the working directory.
Commit migrated from https://github.com/dotnet/corefx/commit/d9465170db0be15a6e8d8ca6ba591a358f709ec5