Move Environment and friends to corefx
authorStephen Toub <stoub@microsoft.com>
Tue, 5 Jul 2016 16:44:40 +0000 (12:44 -0400)
committerStephen Toub <stoub@microsoft.com>
Tue, 5 Jul 2016 18:09:16 +0000 (14:09 -0400)
commit7b5e7af912853db2b97b2cf66b641ff9883cd0be
tree0e98c55432e3af1c3e9b6902c31d78bc1db8c12a
parent4dfc82bf5d8a41fa11a4e677f677f87871667082
Move Environment and friends to corefx

Currently System.Runtime.Extensions type forwards to the Environment in the runtime, which means we need to implement functionality in both coreclr and corert.  It's also missing functionality, which means to add that functionality back we'd need to do so in both runtimes, and we'd miss out on sharing code with elsewhere in corefx.

This commit:
1) Adds Environment, EnvironmentVariableTarget, OperatingSystem, and PlatformID to corefx so that System.Runtime.Extensions contains the type rather than forwarding to it.
2) Adds implementations of all of the missing members: CommandLine, CurrentDirectory, ExitCode, Is64BitProcess, Is64BitOperatingSystem, OSVersion, SystemPageSize, UserInteractive, UserName, UserDomainName, Version, WorkingSet, GetLogicalDrives, GetFolderPath, and the overloads of Get/SetEnvironmentVariable(s) that take an EnvironmentVariableTarget.
3) Adds the additional members to the contract.
4) Adds some basic tests to ensure basic functionality works.

Work that still needs to be done after this:
1) Add an EnvironmentAugments type to System.Private.Corelib in both corefx and corert, use that to replace the reflection-based hack in this commit, then remove the current Environment from Corelib's model.xml so that the rewriter will make it internal.  As part of this, we need to determine how to handle "IsAppXmodel/DesignMode" from corefx, whether we need two different builds for Win32/WinRT, etc.
2) Fix Get/SetEnvironmentVariable(s) to not ignore the EnvironmentVariableTarget.  This should be doable once (1) is done.
3) Add more support to the Unix implementation of GetFolderPath for more special folders
4) Add a GetTickCount method to the System.Native native lib, ala the implementation in libcoreclr; the current implementation is functional but slower than it could be.
5) Implement more Windows functionality if/when missing functions become available: SHGetFolderPath and GetVersionExW.
6) Use GetLogicalProcessInformationEx in ProcessorCount (or delegate to the implementation in coreclr).
I will open issues for each of these prior to merging this commit.

Commit migrated from https://github.com/dotnet/corefx/commit/fe5f4fbebc9e85c8e512a273567719dca15ac764
37 files changed:
src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixRelease.cs [new file with mode: 0644]
src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysConf.cs
src/libraries/Common/src/Interop/Windows/Interop.Libraries.cs
src/libraries/Common/src/Interop/Windows/mincore/Interop.ExpandEnvironmentStringsW.cs [new file with mode: 0644]
src/libraries/Common/src/Interop/Windows/mincore/Interop.GetSystemDirectoryW.cs [new file with mode: 0644]
src/libraries/Common/src/Interop/Windows/mincore/Interop.GetTickCount64.cs [new file with mode: 0644]
src/libraries/Common/src/Interop/Windows/mincore/Interop.GetUserNameExW.cs [new file with mode: 0644]
src/libraries/Common/src/Interop/Windows/mincore/Interop.GetUserNameW.cs [new file with mode: 0644]
src/libraries/Common/src/Interop/Windows/mincore/Interop.GetVersionExW.cs [new file with mode: 0644]
src/libraries/Common/src/Interop/Windows/mincore/Interop.IsWow64Process_IntPtr.cs [new file with mode: 0644]
src/libraries/Common/src/Interop/Windows/mincore/Interop.IsWow64Process_SafeProcessHandle.cs [moved from src/libraries/Common/src/Interop/Windows/mincore/Interop.IsWow64Process.cs with 100% similarity]
src/libraries/Common/src/Interop/Windows/mincore/Interop.LookupAccountNameW.cs [new file with mode: 0644]
src/libraries/Native/System.Native/pal_io.cpp
src/libraries/Native/System.Native/pal_io.h
src/libraries/Native/System.Native/pal_runtimeinformation.cpp
src/libraries/Native/System.Native/pal_runtimeinformation.h
src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj
src/libraries/System.Runtime.Extensions/ref/System.Runtime.Extensions.cs
src/libraries/System.Runtime.Extensions/src/Resources/Strings.resx
src/libraries/System.Runtime.Extensions/src/System.Runtime.Extensions.csproj
src/libraries/System.Runtime.Extensions/src/System/Environment.SpecialFolder.cs [new file with mode: 0644]
src/libraries/System.Runtime.Extensions/src/System/Environment.SpecialFolderOption.cs [new file with mode: 0644]
src/libraries/System.Runtime.Extensions/src/System/Environment.Unix.cs [new file with mode: 0644]
src/libraries/System.Runtime.Extensions/src/System/Environment.Windows.cs [new file with mode: 0644]
src/libraries/System.Runtime.Extensions/src/System/Environment.cs [new file with mode: 0644]
src/libraries/System.Runtime.Extensions/src/System/EnvironmentVariableTarget.cs [new file with mode: 0644]
src/libraries/System.Runtime.Extensions/src/System/OperatingSystem.cs [new file with mode: 0644]
src/libraries/System.Runtime.Extensions/src/System/PlatformID.cs [new file with mode: 0644]
src/libraries/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj
src/libraries/System.Runtime.Extensions/tests/System/Environment.Exit.cs
src/libraries/System.Runtime.Extensions/tests/System/Environment.GetCommandLineArgs.cs
src/libraries/System.Runtime.Extensions/tests/System/Environment.GetEnvironmentVariable.cs
src/libraries/System.Runtime.Extensions/tests/System/Environment.NewLine.cs
src/libraries/System.Runtime.Extensions/tests/System/Environment.ProcessorCount.cs
src/libraries/System.Runtime.Extensions/tests/System/EnvironmentTests.cs [new file with mode: 0644]
src/libraries/System.Runtime.Extensions/tests/System/IO/Path.Combine.cs
src/libraries/System.Runtime.Extensions/tests/System/IO/PathTests.cs