UTF16 encoded files trip up both Git and GitHub since the huristic they
use to determine if a file is binary or not depends on the existence of
null bytes in a file, which is common in UTF-16 encoded source.
This converts all the UTF-16 encoded files into UTF-8 with an explicit
byte order marker.
Commit migrated from https://github.com/dotnet/corefx/commit/b660da388085b5048f7dfc101d6d0634661a30dd
-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
In a few places, we still have platform-specific code in shared System.IO.FileSystem code. In particular, DirectoryInfo is doing various manipulations related to Windows path roots that can result in doing the wrong thing on Unix, e.g. creating a DirectoryInfo for "C:" on Unix should be for the directory named "C:", but instead today it'll follow the Windows-specific logic of rerouting to target the current directory. This commit fixes that. It also moves some code used only in the Windows implementation into Windows-specific files (e.g. Directory.SearchData).
Commit migrated from https://github.com/dotnet/corefx/commit/2450018290375fd5a736d67cca8beec7db3a7c5c
While working on some path-related functionality in System.IO.FileSystem, I noticed that our methods for iterating a directory are taking the enumerable of results, storing that into a list, and then converting that list into an array. This commit changes four such methods to skip the middle-man.
Commit migrated from https://github.com/dotnet/corefx/commit/7b5006b867ffd73e870e1fa56a5be9622d356e7a
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
Previously, System.IO.Path was implemented in mscorlib (with calls into Win32 on Windows / the Win32 PAL layer in libcoreclr on Unix) and type-forwarded from System.Runtime.Extensions. With dotnet/corefx#2234, we switched the Windows build to using System.IO.Path from System.Runtime.Extensions and Path.cs from corefx, but the Unix version was left still using the mscorlib implementation. One of the reasons for switching to the Path.cs in corefx, however, was to better enable a bunch of fixes to the behavior of the Unix implementation.
This change implements Path.cs in corefx for Unix and switches the Unix builds (Linux, OS X, and FreeBSD) over to using the implementation in corefx rather than type-forwarding to mscorlib.
Primary changes:
- Defined MaxPath / MaxComponent length in the Unix build in terms of pathconf
- Implemented the Unix build's NormalizePath to properly handle normalizing unnecessary "/", ".", and ".."s in the path.
- Implemented the Unix build's GetTempPath in terms of the TMPDIR environment variable (same logic that's in the Win32 PAL layer's implementation).
- Implemented the Unix build's GetTempFileName in terms of mkstemps.
- Implemented the Unix build's GetRandomFileName in terms of OpenSSL's RAND_pseudo_bytes, same as is done in System.Security.Cryptography.RandomNumberGenerator (which we can't reference due to layering).
- Centralized the wrapping of getcwd, which is now used from both System.Runtime.Extensions and System.IO.FileSystem. The previous usage of it always created a temporary array of size MaxPath, which can now be quite big, so the wrapper first tries to use stack space, and then graduates to retrying with larger and larger buffer sizes.
- Centralized the MaxPath and MaxName logic, which is now used by three libraries: System.Diagnostics.Process, System.IO.FileSystem, and now System.Runtime.Extensions.
- Centralized the throwing of PathTooLongException, as it now requires arguments for how long are the maximum path and component names.
- Cleaned up a few other minor things in the shared Path.cs (e.g. naming Boolean arguments) that were confusing me as I was working through the code.
- Added FreeBSD to the .sln and .csproj files, as otherwise the FreeBSD build for this library would be broken (previously it inherited the mscorlib implementation as did the other Unix OSes).
- Added a bunch of tests, some general across both Windows and Unix, but others specifically focused on Unix, which is more lenient than is Windows in the paths it allows.
Commit migrated from https://github.com/dotnet/corefx/commit/c4bc3bbfae8a9bf50defcfb8d6e13905f1209240
Today when enumerating directories, we look only for entries with DT_DIR (directory) or DT_REG (regular file); if we encounter something unknown or a symlink, we stat to resolve it and determine whether it's actually an S_IFDIR (directory) or S_IFREG (regular file). There are (at least) two problems with this:
1) The stat to a symlink will fail if the symlink points to a non-existent entry.
2) We end up skipping lots of special files, e.g. FIFOs.
The commit changes our logic to simply special case directories: we treat everything as a file unless we're sure it's a directory. This directly fixes (2), and indirectly fixes (1): our logic for DirectoryExists already ignores any stat errors, returning false if the symlink couldn't be resolved, such that this naturally maps to our desired behavior of broken symlinks being categorized as a file.
Commit migrated from https://github.com/dotnet/corefx/commit/5428c98a421fe7e5907c050a7e820f5045b61e61
-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
Most test projects don't need unsafe code, but many were forced to allow unsafe blocks due to Interop.PlatformDetection.cs using pointers, and others were allowing it for no apparent reason. I've modified Interop.PlatformDetection.cs to not use unsafe code, and updated the relevant test projects accordingly. (Eventually we'll switch it over to using the new RuntimeInformation assembly, anyway.)
Commit migrated from https://github.com/dotnet/corefx/commit/3ae04f6ec948331c85c5f8441cd6d9eda868603f
This adds the bits necessary to build the System.IO.FileSystem assembly for FreeBSD. I moved the Interop.posix_fdadvise.cs from Linux to Unix, since that system call is identical between Linux and FreeBSD. That file is only used for Linux and FreeBSD.
Commit migrated from https://github.com/dotnet/corefx/commit/1dd39be66ac96730992dd89ff775b245582d42b7
Some of the project.json files were referencing xunit.netcore.extensions with ""1.0.0-prerelease" rather than "1.0.0-prerelease-*". As a result, I was unable to use more recent additions, like PlatformID.AnyUnix. This change just updates them to use the -* versions, and changes the few remaining places that were using PlatformID.Linux | PlatformID.OSX to instead use PlatformID.AnyUnix. The project.lock.json files were automatically updated by my building locally.
Commit migrated from https://github.com/dotnet/corefx/commit/f28722e261368de16adc2600fa1f1d3c0993ee8d
Directory.RemoveDirectory is careful not to delete recursively across a volume mount point. It does this by detecting the mount point via file attribute data then using DeleteVolumeMountPointW to break the mount point. This will not work for store apps for two reasons a) unless someone has very loosely ACLed the mount point the API is going to fail with ACCESS_DENIED (UnauthorizedAccessException) b) DeleteVolumeMountPointW is not permitted as part of the modern SDK. To adress b we are just making this API fail in the same way it would normally. We discussed this issue with Windows and this was the reccomended approach.
[tfs-changeset: 1474880]
Commit migrated from https://github.com/dotnet/corefx/commit/184b7bb409be13e1234e411c3f2945d16c1f62ab
This change adds the lock files to repo to ensure we build against a stable set of dependencies. To explicitly update dependencies use build.cmd /T:RestorePackages /P:LockDependencies=true and this will pick up the latest depenedencies.
Existing projects adding new dependencies will automatically update the lock file incrementally.
New projects should make sure to check their lock file in with locked set to true.
[tfs-changeset: 1474296]
Commit migrated from https://github.com/dotnet/corefx/commit/d2fbc005707933db1cebca035d6cd6073af6cae4
Switch usage to new ThreadPoolBoundHandle API. This is relatively
straightforward, since this code didn't really do anything "tricky" like
re-use NativeOverlapped pointers.
Also, Enable overlapped operations in FileStream on N, now that they use
the supported API.
[tfs-changeset: 1474072]
Commit migrated from https://github.com/dotnet/corefx/commit/87270686b2e8d78953d1787422671faaf25eccb9
When we call TrySetCanceled, we want to do so using the CancellationToken that issued the cancellation request. This will ensure that the OperationCanceledException that gets propagated contains that token and can be used for comparisons.
Commit migrated from https://github.com/dotnet/corefx/commit/b85128ccd03808e07678d9c823193cc63c1e20b4
Latest packages are now on dotnet-core myget feed.
This should address a many of the warnings in the build. I will follow up with another change to address the rest.
This change brings in the latest build tools with updates to consume "latest" packages (* versions).
I've updated every project in the repo to use * versioning for dependencies.
The new packages can be used to resolve runtime assets as well (like clrcompression.dll) so I have removed the custom code in System.IO.Compression to copy this dll. Instead the test project references the actual System.IO.Compression package and sets the correct runtime IDs to pull out the resources. The System.IO.Compression.dll from the package is not used since the project reference takes precedence.
I had to workaround an issue in System.Xml.XmlSerializer with the current packages: System.Runtime.WindowsRuntime 4.0.0 has a depedendency on "windows" package which doesn't exist. This was caused by our auto-generation task not filtering the winrt reference in the reference assembly's surface area. I've fixed this in a separate change and we can remove the workaround once we have a new set of packages. https://github.com/dotnet/corefx/issues/1761
I also had to add a dependency to System.Security.Cryptography.Hashing.Algorithms\tests due to an issue with DNX. It's not honoring the dependency group with no targetFramework when another dependency group exists in the nuspec. This is inconsistent with nuget v2 and should be fixed in DNX. https://github.com/aspnet/dnx/issues/1881
[tfs-changeset: 1471885]
Commit migrated from https://github.com/dotnet/corefx/commit/08c0d8628ef621fbd44d7aaa85b3239616a6b108
When FileStream async I/O completes due to cancellation, Windows gives back an error code of ERROR_OPERATION_ABORTED. FileStream is translating this to an OperationCanceledException and then faulting the task with that exception, rather than canceling the task. This commit changes it to cancel the task so that it ends in the Canceled rather than Faulted state.
This fixes a regression introduced by dotnet/corefx#972.
Commit migrated from https://github.com/dotnet/corefx/commit/1e1b8ae3246e722cc082bb53e9ecedfd9c0a0434