Commit Graph
45 Commits
Author SHA1 Message Date
Matt Ellis 91409b75fa Replace Contract.Assert with Debug.Assert
Fixes dotnet/corefx#682


Commit migrated from https://github.com/dotnet/corefx/commit/980e41dc6beef8caf4a4369fea2028e1c7cbaf38
2015-02-11 11:55:51 -08:00
Stephen Toub 02d3286c76 Replace open64 usage with open in Unix libs
Use the POSIX-compliant open function instead of open64.


Commit migrated from https://github.com/dotnet/corefx/commit/e2ad5a8a55b7167286dfa3e45af6c97e59485abd
2015-02-10 01:05:33 -05:00
Maxwe11 2d635dae1c Replace relative path to common tests with a variable
Replace relative path "..\..\Common\tests" with $(CommonTestPath) variable.


Commit migrated from https://github.com/dotnet/corefx/commit/56dbc6abc6dcde5874c99c67f379d788c8dd4420
2015-02-08 15:05:37 +02:00
Nick Guerrera 96ee8ecc84 Merge pull request dotnet/corefx#688 from dotnet/v1.0
Merge v1.0 -> master

Commit migrated from https://github.com/dotnet/corefx/commit/bd08ac4fe67dd91dac06681a536683f1baf1dada
2015-02-07 15:05:35 -08:00
Matt Mitchell b2149f1c80 Enable code coverage for the corefx repo
This change enables code coverage for the corefx project using OpenCover.

 * When /p:Coverage=true is passed, we wrap the xunit call in the OpenCover command.
 * OpenCover filters test assemblies but no other default filters.
 * We disable parallel execution of tests within xunit and parallel project building when running coverage. This appears to cause issues with OpenCover (I see spurious failures in tests) and is actually slower than just running execution serially.
 * A few assemblies still have issues even after this.  These have coverage disabled with CoverageEnabledForProject.  Will open an issue for future investigation.
 * After execution is complete, we run the ReportGenerator tool over the set of generated coverage data, creating a full report in bin\tests\coverage.


Commit migrated from https://github.com/dotnet/corefx/commit/60a0bdd4125e39aa1653f2aeffc9eea02f348531
2015-02-05 13:11:18 -08:00
Eric StJohn ec247073ff Fix DirectoryInfo.Exists for search results
We have a seperate codepath for initializing DirectoryInfos when they are the result of
search.  We do this as a performance optimization since we already have the filesystem
data for the directory/file.  I was missing the flag that set the internal field as directory/file
in this codepath, which resulted in DirectoryInfo.Exists treating the item as a file and
returning false since it had the Directory attribute set.

I've fixed this omission and added some tests for DirectoryInfo.Exists.


Commit migrated from https://github.com/dotnet/corefx/commit/ea4b8d6b96c9687b431c1c5785a582caa9a22912
2015-02-04 14:33:14 -08:00
Nick Guerrera 185d6e3315 Merge pull request dotnet/corefx#605 from dotnet/v1.0
Merge v1.0 to master

Commit migrated from https://github.com/dotnet/corefx/commit/4500cb29e292efd68a0df97224bc94a6af864683
2015-02-02 15:09:48 -08:00
Stephen Toub e2750b7176 Change sync File helpers to use sync FileStreams
.NET Core currently uses a default of useAsync=true for FileStreams.  But File has several synchronous helpers, e.g. ReadAllBytes, which create FileStreams using the default, don't hand the FileStream out externally, and only perform synchronous operations.  This means there's unnecessary overhead related to setting up and executing the underlying asynchronous operation.  This commit simply changes those helpers (ReadAllBytes, WriteAllText, etc.) to specify that the file should be opened for synchronous rather than asynchronous I/O.

The performance improvement depends on a variety of factors, including the size of the file being read/written, the number of operations involved in reading/writing the file, etc.  I tried a bunch of combinations and contents, and didn't see any regressions.  In a variety of cases though I did see measurable improvements, e.g.
- ReadAllBytes on a 1K file improved throughput by ~30%.
- ReadAllText on a 10MB file improved throughput by ~20%
- WriteAllBytes on a 4K file improved throughput by ~18%
Note that these were all microbenchmarks, executing these operations repeatedly in order to make them more easily measurable.


Commit migrated from https://github.com/dotnet/corefx/commit/12a1df91cec56ea2dbee6e10160909e1a8b775e6
2015-02-01 16:59:48 -05:00
Stephen Toub 0ce419eaa6 Remove buffer allocation from File.ReadAllBytes
ReadAllBytes is creating a FileStream with the default buffer size of 4K.  Since we've already allocated a byte array large enough to hold the entire file, the internal buffer allocated in FileStream is pure overhead, both for the allocation itself and also for the extra copy of data through the buffer.

This commit fixes this simply by explicitly setting the bufferSize to 1.  FileStream lazily-allocates the buffer, only creating and using it if it needs it.  If a read comes in for a size greater than or equal to the bufferSize, it'll skip the buffer.  So, previously, when reading a file > 4K in size, the buffer would be avoided; now it's also avoided for files <= 4K in size.

A microbenchmark repeatedly caling ReadAllBytes showed that with this fix the number of gen0 GCs caused by its usage dropped anywhere from 0-10x, depending on the size of the file being read.  Throughput improved by a few percentage points as well.

(Note that I also tried this same change for WriteAllBytes.  While it did have a similar effect on gen0 GCs, it caused a surprising regression in throughput, upwards of 20%, and I did not further dig into why.  I also noticed that at the moment FileStream in .NET Core is defaulting to useAsync=true, which is different from the desktop and doesn't make much sense for {Read/Write}AllBytes; if that default remains the same, we should explicitly set useAsync=false for these methods.)


Commit migrated from https://github.com/dotnet/corefx/commit/7f84dfbc13bba30caf8938ca1edd565ba2f42c62
2015-01-31 22:54:44 -05:00
Nick Guerrera 05c7646f02 Merge pull request dotnet/corefx#576 from dotnet/v1.0
Merge v1 to master

Commit migrated from https://github.com/dotnet/corefx/commit/3203415188a03592028795f3e559bad861cf39fa
2015-01-30 14:09:45 -08:00
Stephen Toub 358232dc81 Fix Unix build of file system
Commit migrated from https://github.com/dotnet/corefx/commit/471027bd1d36ce7d69e40e5af9f0b9eafda16ac5
2015-01-30 16:51:14 -05:00
Nick Guerrera f076e50a56 Merge pull request dotnet/corefx#565 from dotnet/v1.0
Merge v1.0 to master

Commit migrated from https://github.com/dotnet/corefx/commit/593d5b40e188ba23f656fd93efabdff390048b34
2015-01-29 19:13:11 -08:00
Eric StJohn 447d1f6d58 Merge branch 'v1.0' into fileSystemTests
Conflicts:
	src/System.IO.FileSystem/tests/packages.config - updated version


Commit migrated from https://github.com/dotnet/corefx/commit/7d8cde6b1684d161a296701dc2666f926bd403da
2015-01-29 11:27:59 -08:00
Nick Guerrera 2c69e7b094 Merge pull request dotnet/corefx#555 from dotnet/v1.0
Merge v1.0 to master

Commit migrated from https://github.com/dotnet/corefx/commit/1ea0f1ef443e3d5de322cadedc39825933c04571
2015-01-29 10:46:15 -08:00
Stephen Toub de2fbd0e9a Fix formatting PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/77d1ae4a41b05f560bb82162aae5a5b4ee770ca8
2015-01-29 12:34:47 -05:00
Eric StJohn 7d8414110d Merge branch 'v1.0' into fileSystemTests
Commit migrated from https://github.com/dotnet/corefx/commit/eb6d72289053b56a1bab1d20e8abbd643ff0e85e
2015-01-29 08:52:13 -08:00
Eric StJohn 485f6da00e Testing the return value of Seek
Commit migrated from https://github.com/dotnet/corefx/commit/9288809a29883edbcd58c0a51ee7bd3b13be278e
2015-01-29 08:51:20 -08:00
Eric StJohn 2f422d1fba Refactoring CompletesSynchronously to better test the that an async method completes synchronously.
Commit migrated from https://github.com/dotnet/corefx/commit/a35bcce6f747981e830a3824aad62503c6da12e2
2015-01-29 08:50:51 -08:00
Nick Guerrera 1846be8d13 Bump package versions to 22512
Commit migrated from https://github.com/dotnet/corefx/commit/fa62bc6d0ab5e2b413c8930c708969029616a8e0
2015-01-28 17:46:49 -08:00
Stephen Toub 0550d7eecd Refactor Unix interop
As we've discussed offline, we want to change how we're structuring
our interop code, in particular to make it easier to share interop
definitions across assemblies.  This commit is an initial refactoring
of our existing Unix interop code to follow the new approach.


Commit migrated from https://github.com/dotnet/corefx/commit/000519fbfa654655410c5cf204d74006faa763fa
2015-01-27 11:34:58 -05:00
Stephen Toub 6f90a9ec0d Merge v1 to master
Commit migrated from https://github.com/dotnet/corefx/commit/5cdde5b80e3b588109dbe1dc0aca866d7eae1462
2015-01-26 09:36:12 -05:00
Eric StJohn 09489674ad Adding tests for FileStream.
Commit migrated from https://github.com/dotnet/corefx/commit/75dd80ef6fc260e8d5dca8458d8baf9e3faa35a7
2015-01-23 10:57:01 -08:00
Eric StJohn ebf15ad34b Routing virtual calls from internal FileStream implementations through public FileStream so that derived FileStreams can override the behavior. Also eliminating all virtual calls from construction.
Commit migrated from https://github.com/dotnet/corefx/commit/1a9bc4b949749b68f70048d0fe85168bea735122
2015-01-23 10:55:38 -08:00
Nick Guerrera 18d59d59f1 Remove PLIB ProjectTypeGuids to allow editing debug options in VS
We control the targeting centrally and we shouldn't be retargeting
from VS. With the new support for running tests on F5, it is best
to be able to see and edit the command line in the property pages.

Before this, we had an arbitrary mix of the guids being present or
not anyhow. At some point, if we need to set it, we can put it back
across the board and hopefully by then we'll have proper VS test
integration anyhow.


Commit migrated from https://github.com/dotnet/corefx/commit/da9663498c4f5e6bb663e97531afc48964ffbdd0
2015-01-22 16:30:00 -08:00
Bruce Bowyer-Smyth d10fcb4771 Change SafeFileHandle and SafeFindHandle (Windows) to use IntPtr.Zero instead of new IntPtr(0)
Commit migrated from https://github.com/dotnet/corefx/commit/b115cb8bfbf3d0576e3b74acfdda4340ab0b5522
2015-01-17 06:26:54 +10:00
joshfree e3fa23c56e Trivial cleanup to use Assert.True(x) and Assert.False(x)
Search and replace across all tests :
  Assert.Equal(true, x); => Assert.True(x);
  Assert.Equal(false, x); => Assert.False(x);

Changed files:
  System.Collections.NonGeneric.Tests.dll
  System.IO.FileSystem.Tests.dll
  System.Reflection.Metadata.Tests.dll


Commit migrated from https://github.com/dotnet/corefx/commit/1199340b63d39afc47d502a7474c777a07a89ad3
2015-01-15 16:43:31 -08:00
Matt Cohn 06d79a728d Merge branch 'master' into netcore
Commit migrated from https://github.com/dotnet/corefx/commit/c94808955e5557e902c20e640c6e8fb7d5115b3a
2015-01-12 19:03:39 -08:00
Matt Cohn 17ac717a13 Port test libraries to netcore xunit
Commit migrated from https://github.com/dotnet/corefx/commit/38714568bdcb3477486783e5cfbc2ba24d678186
2015-01-12 19:02:47 -08:00
Stephen Toub e945f727db Address PR feedback to use char.ToString()
Commit migrated from https://github.com/dotnet/corefx/commit/b1cfa0dfc8db08f97470a22bb12afebbe841090c
2015-01-12 01:06:42 -05:00
Stephen Toub 93d8242941 Remove unnecessary char-related allocations
This commit removes several unnecessary char-related allocations in System.IO.FileSystem.  Most of them stemmed from appending the DirectorySeparatorChar to a string, which results in the compiler using String.Concat(..., object) for the concatenation, which means the char gets boxed.  Others stemmed from array allocations that could have been cached, e.g. allocating an array for the directory separator chars on each call to TrimEnd.

In fixing these, I also noticed and fixed a few places where duplicated logic could be replaced with a call to IsDirectoryChar.


Commit migrated from https://github.com/dotnet/corefx/commit/b5d327ac0ad50488c801b716b69521be6a6720c9
2015-01-11 20:29:29 -05:00
Alexander Köplinger 3be6bb17ce Remove unused namespace and fix package reference in FS
The System.Runtime.Serialization namespace isn't defined in any of the
NuGet packages and is not used in the project, so it can be removed.

The System.IO.FileSystem tests were missing a reference to
System.Runtime.Handles in packages.config (SafeHandle is defined there).

This fixes compilation errors on the Mono compiler.


Commit migrated from https://github.com/dotnet/corefx/commit/11f161176d4b1823f47d35d651a027a892f4e1ad
2015-01-08 21:26:52 +01:00
Alexander Köplinger 1d07acf933 Canonicalize MSBuild ToolsVersion to 12.0
Like 57cffc78, but for the recently added projects.


Commit migrated from https://github.com/dotnet/corefx/commit/fc09d0ab4b31d64744f3aa052bde3419d9be5af9
2015-01-08 14:28:58 +01:00
Stephen Toub b21e5eb709 Merge pull request dotnet/corefx#351 from stephentoub/removefilestreamclosure
Avoid unnecessary closure in Win32FileStreamAsyncResult

Commit migrated from https://github.com/dotnet/corefx/commit/267b8c1edebc1ed5d238db256c412c8a874a62f7
2015-01-06 17:54:11 -05:00
Stephen Toub 935dd387e8 Merge pull request dotnet/corefx#349 from stephentoub/taskhelpers
TaskHelpers cleanup

Commit migrated from https://github.com/dotnet/corefx/commit/cbdab07eb48962aeca89eb42e3576c4daf8ec84e
2015-01-06 17:44:35 -05:00
Stephen Toub be82c7d600 Fix missing file updates from System.IO.FileSystem
When System.IO.FileSystem was added to the repo, changes made to SafeFileHandle did not migrate with it.  There was also a file reference missing from the .csproj file.  Both of these broke the Unix build.  This change just brings those back in sync.


Commit migrated from https://github.com/dotnet/corefx/commit/49ea84c45b466d90ef4490a49976ea7b498287a0
2015-01-06 17:26:54 -05:00
Stephen Toub 9449b84160 Avoid unnecessary closure in Win32FileStreamAsyncResult
Commit migrated from https://github.com/dotnet/corefx/commit/d48889085f8f7391c1958ffbf5d951f3ea3d6487
2015-01-06 12:04:34 -05:00
Eric StJohn bcf12fecdd Updating stale comment that referred to the unusual behavior of FileSystem's ReadLinesIterator.
Commit migrated from https://github.com/dotnet/corefx/commit/e350515a0bfe627542c49cb04691c1df94712963
2015-01-06 08:54:04 -08:00
Stephen Toub bb67b01d51 TaskHelpers cleanup
TaskHelpers.cs is a temporary stop-gap for assemblies that don't yet depend on the latest System.Threading.Tasks contract. This change removes the dependency for those assemblies that do, changing them to use the Task.CompletedTask, Task.FromCanceled, and Task.FromException members on Task instead of the corresponding workarounds on TaskHelpers.  This file should eventually go away entirely.


Commit migrated from https://github.com/dotnet/corefx/commit/325e24de73b86c2b1f920109afe06faedb42b3d8
2015-01-06 09:23:52 -05:00
Eric StJohn 3bd6b8da9b Add test assertions for exception members of FileStreeam.ctor(string, fileMode) tests.
Commit migrated from https://github.com/dotnet/corefx/commit/be8527cc02ddf065ff0cab1ddecd93b92e245dc6
2014-12-30 15:52:36 -08:00
Eric StJohn 48a3156ab1 Update style of FileSystemTest to match guidelines.
Commit migrated from https://github.com/dotnet/corefx/commit/3f2d06d971fa5ca0c42d8bb0c354b6eef046f68e
2014-12-30 14:40:30 -08:00
Eric StJohn 874cbd5d8b Fix API comments on FileSystem enums to have valid XML.
Commit migrated from https://github.com/dotnet/corefx/commit/4eedcb11fe8c6f72f9be4813b69c026dbba29c42
2014-12-30 14:39:50 -08:00
Eric StJohn 3b16d158af Split PathInternal between Windows and Unix implementation since platforms have different invalid path characters. Fix issue with FileStream where it was throwing for valid chars (* and ?) on Unix.
Commit migrated from https://github.com/dotnet/corefx/commit/d9607338af7bb376f227438f67fe09280b919564
2014-12-30 14:36:27 -08:00
Eric StJohn 6923cfab70 Add projects for FileSystem and FileSystem.Primitives. Add tests for FS.Primitives and the begining of tests for FileSystem.
Commit migrated from https://github.com/dotnet/corefx/commit/5b0e138913de4854ed2a4c627fa75362413d2010
2014-12-29 12:45:05 -08:00
Eric StJohn 4ee2e489bb Addressing API feedback for System.IO.FileSystem.
This change adds (back) the following APIs:
Directory.GetParent
Directory.GetCreationTimeUtc
Directory.SetCreationTimeUtc
Directory.GetLastAccessTimeUtc
Directory.SetLastAccessTimeUtc
Directory.GetLastWriteTimeUtc
Directory.SetLastWriteTimeUtc
File.Create(..., FileOptions options)
File.GetCreationTimeUtc
File.SetCreationTimeUtc
File.GetLastAccessTimeUtc
File.SetLastAccessTimeUtc
File.GetLastWriteTimeUtc
File.SetLastWriteTimeUtc
string[] File.ReadAllLines(...)
FileInfo.IsReadOnly
FileSystemInfo.CreationTimeUtc
FileSystemInfo.LastAccessTimeUtc
FileSystemInfo.LastWriteTimeUtc
FileAttributes.IntegrityStream
FileAttributes.NoScrubData


Commit migrated from https://github.com/dotnet/corefx/commit/9698f579f05430e29a9149b3a4a7e5b17f76fb4b
2014-12-23 12:12:49 -08:00
dotnet-bot a59e0991e6 Initial commit of System.IO.FileSystem and System.IO.FileSystem.Primitives
Commit migrated from https://github.com/dotnet/corefx/commit/fda256397e23e60a15a4f0639783d99bd55069b4
2014-12-19 11:45:04 -08:00