Several libraries had their code coverage disabled due to unknown problems. The change to a more recent version of OpenCover appears to have addressed whatever those issues were, as the problems no longer repro. This commit just re-enables the code coverage for those libraries.
The only remaining library with its code coverage disabled is System.Diagnostics.Process.dll. It's either hanging or just taking a really long time to complete. Investigation still needed.
Commit migrated from https://github.com/dotnet/corefx/commit/01c18f27d5a6c383701e0407b55e6edfae203309
We were previously just using the exact path provided as the ProcessStartInfo.Filename. With this commit, we now use the same basic path resolution logic as is used on Windows (except for Windows-specific aspects): the specified path if it's absolute, then the executable's directory, then the current directory, and then each of the directories in the PATH environment variable.
Commit migrated from https://github.com/dotnet/corefx/commit/091b73b54451f777f751cf44460211639043e9b9
As part of this, changed interop definitions of off_t to be Int64 rather than IntPtr. For now we're assuming that we'll run either on 64-bit systems and/or where _FILE_OFFSET_BITS == 64. We can revisit this if that assumption fails.
Commit migrated from https://github.com/dotnet/corefx/commit/198d30af095675a8eaaa387d14c68621065fecbd
This is an initial implementation of the System.Diagnostics.Process
assembly for Linux. There are some rough edges here: basic process
enumeration and inspection should work, as should waiting for processes
through various means (WaitForExit, Exited event, etc.), but other
functionality isn't ready for primetime yet, namely Start, which has been
roughly implemented but which hasn't been tested yet.
Some of the surface area doesn't have good equivalents on Linux. Where I
thought it reasonable, in some cases I just left default values in place
or ignore things. In other cases, I throw PlatformNotSupportedException.
We can tweak this over time.
The implementation gets most of its data from the procfs file system.
Suppot for waiting is the most complicated area of the implementation, and
probably still has a few bugs to sort out.
Commit migrated from https://github.com/dotnet/corefx/commit/7a6874e2b84d62b3ece397ae692ee79e330afaa5
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
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
.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
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
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
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
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
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
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