After this change we are going to have unified model for handling resources which is we always use resx files placed under Resources folder and the code will be automatically generated in SR.cs file.
We’ll access ant string resource using the SR class (e.g. SR.ArgumentException).
Commit migrated from https://github.com/dotnet/corefx/commit/db7180f04ef9789a7f199fcd9f8c527990e14673
In MultiplexingWin32WinRTFileSystem we were treating all Opens as potentially
creating a file. As a result we would walk up the path until we found some
existing folder (or failure) so that we could give the FileSystem implementation
a chance to fill in the entire missing path on a create. This was incorrect
for Open operations (FileMode.Open and FileMode.Truncate) and resulted
in poorer performance for Open as well as incorrect exceptions.
Commit migrated from https://github.com/dotnet/corefx/commit/ee3e4566814cf96c0f517d340f221a9472a4df2d
We were using FindFirstFileEx to get file attributes in order to determine if
the file/directory is accessible by Win32. This is failing for root folders in
ApplicationData locations, even though they are accessible by Win32. The
reason seems to be that FindFirstFileEx on a full path requires that the parent
have permission to enumerate contents, even though we've passed a full
path and have full access to that path (likely a bug in FindFirstFileEx).
Using GetFileAttributesEx is better in most cases since it is faster and does
not require permission to enumerate contents. I've switched to using
GetFileAttributesEx first and only falling back to FindFirstFile when we might
have a reparse point that could be a placeholder file.
Commit migrated from https://github.com/dotnet/corefx/commit/cd0216d3350ed210f9bdbf6c083ce020655a105d
For projects that have OS-specific implementations, this change modifies
their solution and project files to create OS-specific configurations.
Rather than just having a Debug or Release option, in Visual Studio a
developer can now select OS_Debug or OS_Release, e.g. for a project that
has a Windows implementation and a Unix implementation, Windows_Debug,
Windows_Release, Unix_Debug, and Unix_Release will all be available
options. Changing the configuration will update the properties used to
configure conditional includes, build outputs, etc.
Commit migrated from https://github.com/dotnet/corefx/commit/d3b259b89877e4a52d12c08e0f9031f37cb0905b
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