Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Expose remaining Environment.* public surface area from System.Private.Corelib#6006

Closed
stephentoub wants to merge 1 commit into
dotnet:masterfrom
stephentoub:add_back_environment
Closed

Expose remaining Environment.* public surface area from System.Private.Corelib#6006
stephentoub wants to merge 1 commit into
dotnet:masterfrom
stephentoub:add_back_environment

Conversation

@stephentoub
Copy link
Copy Markdown
Member

Known issues to address subsequently (I'll open issues for them):

  • Environment.WorkingSet returns 0 on Unix. We should put that in the PAL and provide a real implementation.
  • Environment.SystemDirectory returns "/" on Unix. Not sure if there's a better answer.
  • Environment.Is64BitOperatingSystem returns IntPtr.Size == 8 on Unix, which isn't necessarily correct. We should come up with a better solution, such as querying uname.
  • Environment.GetFolderPath on both Windows and Unix is currently taking the code path written for Windows Phone, such that only SpecialFolder.System is implemented and everything else throws PlatformNotSupportedException.
  • Environment.CommandLine on Unix appears to be returning only argv[0].
  • Plus the relevant ref file needs to be updated in corefx and tests added there. My testing thus far was limited to a few calls to each method via reflection.

cc: @jkotas, @danmosemsft, @weshaggard

@stephentoub stephentoub added this to the 1.1.0 milestone Jun 26, 2016
// 64-bit programs run only on 64-bit
return true;
#elif PLATFORM_UNIX
return IntPtr.Size == 8; // TODO: use uname and match utsname.machine?
Copy link
Copy Markdown
Member

@jkotas jkotas Jun 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We made simplifying assumption that OS architecture == Process architecture in System.Runtime.InteropServices.RuntimeInformation:

https://github.com/dotnet/corefx/blob/d0dc5fc099946adc1035b34a8b1f6042eddb0c75/src/Native/System.Native/pal_runtimeinformation.cpp#L37

The same simplifying assumption should apply here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same simplifying assumption should apply here

Meaning Is64BitProcess should always equal Is64BitOperatingSystem, both of which should be true iff BIT64 is set, and both of which should be true iff IntPtr.Size == 8?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct - on Unix.

@danmoseley
Copy link
Copy Markdown
Member

:shipit:

Comment thread src/mscorlib/model.xml
<Member Name="get_Is64BitOperatingSystem" />
<Member Name="get_MachineName" />
<Member Name="get_NewLine" />
<Member Name="get_OSVersion" />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any ideas what OSVersion returns for non-windows?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weshaggard: It breaks with error message OSVersion's call to GetVersionEx failed., because an attempt is made to call Windows API functions:

internal static OperatingSystem OSVersion

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Jun 30, 2016

Environment.CommandLine on Unix appears to be returning only argv[0]

This will need to be synthetized from GetCommandLineArgs() to get the subset of the command line passed in by the CoreCLR host, even on Windows.

Mono has some code for it already: https://github.com/mono/mono/blob/master/mcs/class/corlib/System/Environment.cs#L128

@stephentoub
Copy link
Copy Markdown
Member Author

I'm going to close this and put up a PR instead to add Environment to CoreFx. Then I'll submit PRs to add an EnvironmentAugments class to CoreCLR and CoreRT that can be used by that type.

@riQQ
Copy link
Copy Markdown

riQQ commented Jan 19, 2023

The EnvironmentAugments PR is in #6205.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants