From: Jan Kotas Date: Mon, 27 Dec 2021 18:07:34 +0000 (-1000) Subject: Move System.Runtime.InteropServices.RuntimeInformation to CoreLib (#63140) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~11704 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=00c169230672b48ff2c77df9ac18aeae0a55ee6a;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Move System.Runtime.InteropServices.RuntimeInformation to CoreLib (#63140) - Makes RuntimeInformation.ProcessArchitecture a JIT/AOT-time constant (constant returning property) - Eliminates tiny netcoreapp assembly with just a few types Fixes #57152 Contributes to #2138 --- diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj index fd9a326..f62c8b9 100644 --- a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -68,6 +68,7 @@ x86 + $(DefineConstants);TARGET_X86 arm diff --git a/src/coreclr/nativeaot/Directory.Build.props b/src/coreclr/nativeaot/Directory.Build.props index 8807dca..dddbec1 100644 --- a/src/coreclr/nativeaot/Directory.Build.props +++ b/src/coreclr/nativeaot/Directory.Build.props @@ -70,7 +70,7 @@ x86 - TARGET_32BIT;$(DefineConstants) + TARGET_32BIT;TARGET_X86;$(DefineConstants) arm diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessArchitecture.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessArchitecture.cs deleted file mode 100644 index 2086b4a..0000000 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessArchitecture.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - [SuppressGCTransition] - [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetProcessArchitecture")] - internal static partial int GetProcessArchitecture(); - } -} diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ProcessorArchitecture.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ProcessorArchitecture.cs deleted file mode 100644 index 8b1ad55..0000000 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ProcessorArchitecture.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - internal enum ProcessorArchitecture - { - x86, - x64, - ARM, - ARM64, - WASM, - S390x - } - } -} diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SYSTEM_INFO.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SYSTEM_INFO.cs index 097c8a3..00c42fc 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SYSTEM_INFO.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SYSTEM_INFO.cs @@ -24,14 +24,9 @@ internal static partial class Interop internal short wProcessorRevision; } - internal enum ProcessorArchitecture : ushort - { - Processor_Architecture_INTEL = 0, - Processor_Architecture_ARM = 5, - Processor_Architecture_IA64 = 6, - Processor_Architecture_AMD64 = 9, - Processor_Architecture_ARM64 = 12, - Processor_Architecture_UNKNOWN = 0xFFFF - } + internal const int PROCESSOR_ARCHITECTURE_INTEL = 0; + internal const int PROCESSOR_ARCHITECTURE_ARM = 5; + internal const int PROCESSOR_ARCHITECTURE_AMD64 = 9; + internal const int PROCESSOR_ARCHITECTURE_ARM64 = 12; } } diff --git a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx index 8e4ff90..57a9c28 100644 --- a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx +++ b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx @@ -3679,11 +3679,8 @@ Unknown value for the ResourceScope: {0} Too many resource visibility bits may be set. - - The parameter '{0}' cannot be an empty string. - - - ApplicationId cannot have an empty string for the name. + + The value cannot be an empty string. FrameworkName is invalid. diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index bfee74c..24b049b 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -770,6 +770,7 @@ + @@ -841,6 +842,7 @@ + @@ -852,6 +854,8 @@ + + @@ -1556,6 +1560,9 @@ Common\Interop\Windows\Kernel32\Interop.GetModuleFileName.cs + + Common\Interop\Windows\Kernel32\Interop.GetNativeSystemInfo.cs + Common\Interop\Windows\Kernel32\Interop.GetOverlappedResult.cs @@ -1858,6 +1865,7 @@ + @@ -1976,6 +1984,9 @@ Common\Interop\Unix\System.Native\Interop.GetHostName.cs + + Common\Interop\Unix\System.Native\Interop.GetOSArchitecture.cs + Common\Interop\Unix\System.Native\Interop.GetProcessPath.cs @@ -1991,6 +2002,9 @@ Common\Interop\Unix\System.Native\Interop.GetUnixName.cs + + Common\Interop\Unix\System.Native\Interop.GetUnixVersion.cs + Common\Interop\Unix\System.Native\Interop.GetUnixRelease.cs @@ -2143,6 +2157,7 @@ + @@ -2191,6 +2206,7 @@ + diff --git a/src/libraries/System.Private.CoreLib/src/System/ApplicationId.cs b/src/libraries/System.Private.CoreLib/src/System/ApplicationId.cs index 97c6338..ed537c2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ApplicationId.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ApplicationId.cs @@ -13,7 +13,7 @@ namespace System public ApplicationId(byte[] publicKeyToken, string name, Version version, string? processorArchitecture, string? culture) { if (name == null) throw new ArgumentNullException(nameof(name)); - if (name.Length == 0) throw new ArgumentException(SR.Argument_EmptyApplicationName); + if (name.Length == 0) throw new ArgumentException(SR.Argument_EmptyString, nameof(name)); if (version == null) throw new ArgumentNullException(nameof(version)); if (publicKeyToken == null) throw new ArgumentNullException(nameof(publicKeyToken)); diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/Architecture.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Architecture.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/Architecture.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Architecture.cs diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/OSPlatform.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/OSPlatform.cs similarity index 97% rename from src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/OSPlatform.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/OSPlatform.cs index 3416867..cf6c8af 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/OSPlatform.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/OSPlatform.cs @@ -20,7 +20,7 @@ namespace System.Runtime.InteropServices private OSPlatform(string osPlatform) { if (osPlatform == null) throw new ArgumentNullException(nameof(osPlatform)); - if (osPlatform.Length == 0) throw new ArgumentException(SR.Argument_EmptyValue, nameof(osPlatform)); + if (osPlatform.Length == 0) throw new ArgumentException(SR.Argument_EmptyString, nameof(osPlatform)); Name = osPlatform; } diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Browser.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Browser.cs similarity index 82% rename from src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Browser.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Browser.cs index c702ef8..3fcfb14 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Browser.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Browser.cs @@ -8,7 +8,5 @@ namespace System.Runtime.InteropServices public static string OSDescription => "Browser"; public static Architecture OSArchitecture => Architecture.Wasm; - - public static Architecture ProcessArchitecture => Architecture.Wasm; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.ProcessArchitecture.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.ProcessArchitecture.cs new file mode 100644 index 0000000..298d039 --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.ProcessArchitecture.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Runtime.InteropServices +{ + public static partial class RuntimeInformation + { + public static Architecture ProcessArchitecture +#if TARGET_X86 + => Architecture.X86; +#elif TARGET_AMD64 + => Architecture.X64; +#elif TARGET_ARM + => Architecture.Arm; +#elif TARGET_ARM64 + => Architecture.Arm64; +#elif TARGET_WASM + => Architecture.Wasm; +#elif TARGET_S390X + => Architecture.S390x; +#else +#error Unknown Architecture +#endif + } +} diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Unix.cs new file mode 100644 index 0000000..1dac29e --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Unix.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; + +namespace System.Runtime.InteropServices +{ + public static partial class RuntimeInformation + { + private static string? s_osDescription; + private static volatile int s_osArchPlusOne; + + public static string OSDescription => s_osDescription ??= Interop.Sys.GetUnixVersion(); + + public static Architecture OSArchitecture + { + get + { + int osArch = s_osArchPlusOne - 1; + + if (osArch < 0) + { + osArch = Interop.Sys.GetOSArchitecture(); + if (osArch < 0) + osArch = (int)ProcessArchitecture; + s_osArchPlusOne = osArch + 1; + } + + Debug.Assert(osArch >= 0); + return (Architecture)osArch; + } + } + } +} diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Windows.cs similarity index 54% rename from src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Windows.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Windows.cs index 636b5fd..594b6cd 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Windows.cs @@ -8,8 +8,7 @@ namespace System.Runtime.InteropServices public static partial class RuntimeInformation { private static string? s_osDescription; - private static volatile int s_osArch = -1; - private static volatile int s_processArch = -1; + private static volatile int s_osArchPlusOne; public static string OSDescription { @@ -36,61 +35,38 @@ namespace System.Runtime.InteropServices { get { - Debug.Assert(sizeof(Architecture) == sizeof(int)); + int osArch = s_osArchPlusOne - 1; - int osArch = s_osArch; - - if (osArch == -1) + if (osArch < 0) { Interop.Kernel32.SYSTEM_INFO sysInfo; unsafe { Interop.Kernel32.GetNativeSystemInfo(&sysInfo); } + osArch = (int)Map(sysInfo.wProcessorArchitecture); - osArch = s_osArch = (int)Map((Interop.Kernel32.ProcessorArchitecture)sysInfo.wProcessorArchitecture); + s_osArchPlusOne = osArch + 1; } + Debug.Assert(osArch >= 0); return (Architecture)osArch; } } - public static Architecture ProcessArchitecture - { - get - { - Debug.Assert(sizeof(Architecture) == sizeof(int)); - - int processArch = s_processArch; - - if (processArch == -1) - { - Interop.Kernel32.SYSTEM_INFO sysInfo; - unsafe - { - Interop.Kernel32.GetSystemInfo(&sysInfo); - } - - processArch = s_processArch = (int)Map((Interop.Kernel32.ProcessorArchitecture)sysInfo.wProcessorArchitecture); - } - - return (Architecture)processArch; - } - } - - private static Architecture Map(Interop.Kernel32.ProcessorArchitecture processorArchitecture) + private static Architecture Map(int processorArchitecture) { switch (processorArchitecture) { - case Interop.Kernel32.ProcessorArchitecture.Processor_Architecture_ARM64: + case Interop.Kernel32.PROCESSOR_ARCHITECTURE_ARM64: return Architecture.Arm64; - case Interop.Kernel32.ProcessorArchitecture.Processor_Architecture_ARM: + case Interop.Kernel32.PROCESSOR_ARCHITECTURE_ARM: return Architecture.Arm; - case Interop.Kernel32.ProcessorArchitecture.Processor_Architecture_AMD64: + case Interop.Kernel32.PROCESSOR_ARCHITECTURE_AMD64: return Architecture.X64; - case Interop.Kernel32.ProcessorArchitecture.Processor_Architecture_INTEL: + case Interop.Kernel32.PROCESSOR_ARCHITECTURE_INTEL: default: - Debug.Assert(processorArchitecture == Interop.Kernel32.ProcessorArchitecture.Processor_Architecture_INTEL, "Unidentified Architecture"); + Debug.Assert(processorArchitecture == Interop.Kernel32.PROCESSOR_ARCHITECTURE_INTEL, "Unidentified Architecture"); return Architecture.X86; } } diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.cs similarity index 100% rename from src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.cs diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/FrameworkName.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/FrameworkName.cs index 7cff546..6bc4bf0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/FrameworkName.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/FrameworkName.cs @@ -104,7 +104,7 @@ namespace System.Runtime.Versioning identifier = identifier.Trim(); if (identifier.Length == 0) { - throw new ArgumentException(SR.Format(SR.net_emptystringcall, nameof(identifier)), nameof(identifier)); + throw new ArgumentException(SR.Argument_EmptyString, nameof(identifier)); } if (version == null) { @@ -128,7 +128,7 @@ namespace System.Runtime.Versioning } if (frameworkName.Length == 0) { - throw new ArgumentException(SR.Format(SR.net_emptystringcall, nameof(frameworkName)), nameof(frameworkName)); + throw new ArgumentException(SR.Argument_EmptyString, nameof(frameworkName)); } string[] components = frameworkName.Split(ComponentSeparator); diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/ref/System.Runtime.InteropServices.RuntimeInformation.Forwards.cs b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/ref/System.Runtime.InteropServices.RuntimeInformation.Forwards.cs new file mode 100644 index 0000000..b4661cd --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/ref/System.Runtime.InteropServices.RuntimeInformation.Forwards.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// ------------------------------------------------------------------------------ +// Changes to this file must follow the https://aka.ms/api-review process. +// ------------------------------------------------------------------------------ + +[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.Architecture))] +[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.OSPlatform))] +[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.RuntimeInformation))] diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/ref/System.Runtime.InteropServices.RuntimeInformation.cs b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/ref/System.Runtime.InteropServices.RuntimeInformation.cs deleted file mode 100644 index 576f7b0..0000000 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/ref/System.Runtime.InteropServices.RuntimeInformation.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// ------------------------------------------------------------------------------ -// Changes to this file must follow the https://aka.ms/api-review process. -// ------------------------------------------------------------------------------ - -namespace System.Runtime.InteropServices -{ - public enum Architecture - { - X86 = 0, - X64 = 1, - Arm = 2, - Arm64 = 3, - Wasm = 4, - S390x = 5, - } - public readonly partial struct OSPlatform : System.IEquatable - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public static System.Runtime.InteropServices.OSPlatform FreeBSD { get { throw null; } } - public static System.Runtime.InteropServices.OSPlatform Linux { get { throw null; } } - public static System.Runtime.InteropServices.OSPlatform OSX { get { throw null; } } - public static System.Runtime.InteropServices.OSPlatform Windows { get { throw null; } } - public static System.Runtime.InteropServices.OSPlatform Create(string osPlatform) { throw null; } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } - public bool Equals(System.Runtime.InteropServices.OSPlatform other) { throw null; } - public override int GetHashCode() { throw null; } - public static bool operator ==(System.Runtime.InteropServices.OSPlatform left, System.Runtime.InteropServices.OSPlatform right) { throw null; } - public static bool operator !=(System.Runtime.InteropServices.OSPlatform left, System.Runtime.InteropServices.OSPlatform right) { throw null; } - public override string ToString() { throw null; } - } - public static partial class RuntimeInformation - { - public static string FrameworkDescription { get { throw null; } } - public static System.Runtime.InteropServices.Architecture OSArchitecture { get { throw null; } } - public static string OSDescription { get { throw null; } } - public static System.Runtime.InteropServices.Architecture ProcessArchitecture { get { throw null; } } - public static string RuntimeIdentifier { get { throw null; } } - public static bool IsOSPlatform(System.Runtime.InteropServices.OSPlatform osPlatform) { throw null; } - } -} diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/ref/System.Runtime.InteropServices.RuntimeInformation.csproj b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/ref/System.Runtime.InteropServices.RuntimeInformation.csproj index 57c3f23..f752541 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/ref/System.Runtime.InteropServices.RuntimeInformation.csproj +++ b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/ref/System.Runtime.InteropServices.RuntimeInformation.csproj @@ -4,7 +4,7 @@ $(NetCoreAppCurrent) - + diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/Resources/Strings.resx b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/Resources/Strings.resx deleted file mode 100644 index e554cfe..0000000 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/Resources/Strings.resx +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Value cannot be empty. - - - RuntimeInformation is not supported for Portable Class Libraries. - - \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System.Runtime.InteropServices.RuntimeInformation.csproj b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System.Runtime.InteropServices.RuntimeInformation.csproj index fc9b3ac..94d0c64 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System.Runtime.InteropServices.RuntimeInformation.csproj +++ b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System.Runtime.InteropServices.RuntimeInformation.csproj @@ -1,50 +1,10 @@ - System.Runtime.InteropServices - true + true + $(NetCoreAppCurrent) enable - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Unix.cs b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Unix.cs deleted file mode 100644 index 46b1a85..0000000 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Unix.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; - -namespace System.Runtime.InteropServices -{ - public static partial class RuntimeInformation - { - private static string? s_osDescription; - - public static string OSDescription => s_osDescription ??= Interop.Sys.GetUnixVersion(); - - public static Architecture OSArchitecture { get; } = Map((Interop.Sys.ProcessorArchitecture)Interop.Sys.GetOSArchitecture()); - - public static Architecture ProcessArchitecture { get; } = Map((Interop.Sys.ProcessorArchitecture)Interop.Sys.GetProcessArchitecture()); - - private static Architecture Map(Interop.Sys.ProcessorArchitecture arch) - { - switch (arch) - { - case Interop.Sys.ProcessorArchitecture.ARM: - return Architecture.Arm; - case Interop.Sys.ProcessorArchitecture.x64: - return Architecture.X64; - case Interop.Sys.ProcessorArchitecture.ARM64: - return Architecture.Arm64; - case Interop.Sys.ProcessorArchitecture.WASM: - return Architecture.Wasm; - case Interop.Sys.ProcessorArchitecture.S390x: - return Architecture.S390x; - case Interop.Sys.ProcessorArchitecture.x86: - default: - Debug.Assert(arch == Interop.Sys.ProcessorArchitecture.x86, "Unidentified Architecture"); - return Architecture.X86; - } - } - } -} diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 435594f..b906bc0 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -13419,6 +13419,15 @@ namespace System.Runtime.ExceptionServices } namespace System.Runtime.InteropServices { + public enum Architecture + { + X86 = 0, + X64 = 1, + Arm = 2, + Arm64 = 3, + Wasm = 4, + S390x = 5, + } public enum CharSet { None = 1, @@ -13498,11 +13507,36 @@ namespace System.Runtime.InteropServices Explicit = 2, Auto = 3, } + public readonly partial struct OSPlatform : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public static System.Runtime.InteropServices.OSPlatform FreeBSD { get { throw null; } } + public static System.Runtime.InteropServices.OSPlatform Linux { get { throw null; } } + public static System.Runtime.InteropServices.OSPlatform OSX { get { throw null; } } + public static System.Runtime.InteropServices.OSPlatform Windows { get { throw null; } } + public static System.Runtime.InteropServices.OSPlatform Create(string osPlatform) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } + public bool Equals(System.Runtime.InteropServices.OSPlatform other) { throw null; } + public override int GetHashCode() { throw null; } + public static bool operator ==(System.Runtime.InteropServices.OSPlatform left, System.Runtime.InteropServices.OSPlatform right) { throw null; } + public static bool operator !=(System.Runtime.InteropServices.OSPlatform left, System.Runtime.InteropServices.OSPlatform right) { throw null; } + public override string ToString() { throw null; } + } [System.AttributeUsageAttribute(System.AttributeTargets.Parameter, Inherited=false)] public sealed partial class OutAttribute : System.Attribute { public OutAttribute() { } } + public static partial class RuntimeInformation + { + public static string FrameworkDescription { get { throw null; } } + public static System.Runtime.InteropServices.Architecture OSArchitecture { get { throw null; } } + public static string OSDescription { get { throw null; } } + public static System.Runtime.InteropServices.Architecture ProcessArchitecture { get { throw null; } } + public static string RuntimeIdentifier { get { throw null; } } + public static bool IsOSPlatform(System.Runtime.InteropServices.OSPlatform osPlatform) { throw null; } + } public abstract partial class SafeBuffer : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid { protected SafeBuffer(bool ownsHandle) : base (default(bool)) { } diff --git a/src/libraries/System.Threading.AccessControl/src/Resources/Strings.resx b/src/libraries/System.Threading.AccessControl/src/Resources/Strings.resx index 3503004..1a636cc 100644 --- a/src/libraries/System.Threading.AccessControl/src/Resources/Strings.resx +++ b/src/libraries/System.Threading.AccessControl/src/Resources/Strings.resx @@ -126,9 +126,6 @@ Positive number required. - - Argument cannot be null or empty. - Empty name is not legal. diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index ffad8ee..cb143f5 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -1,4 +1,4 @@ - + false true @@ -54,6 +54,7 @@ x86 + $(DefineConstants);TARGET_X86 arm @@ -69,6 +70,7 @@ AnyCPU + $(DefineConstants);TARGET_WASM diff --git a/src/native/libs/System.Native/entrypoints.c b/src/native/libs/System.Native/entrypoints.c index fe17553..0e54f4b 100644 --- a/src/native/libs/System.Native/entrypoints.c +++ b/src/native/libs/System.Native/entrypoints.c @@ -216,7 +216,6 @@ static const Entry s_sysNative[] = DllImportEntry(SystemNative_GetUnixRelease) DllImportEntry(SystemNative_GetUnixVersion) DllImportEntry(SystemNative_GetOSArchitecture) - DllImportEntry(SystemNative_GetProcessArchitecture) DllImportEntry(SystemNative_SearchPath) DllImportEntry(SystemNative_SearchPath_TempDirectory) DllImportEntry(SystemNative_RegisterForSigChld) diff --git a/src/native/libs/System.Native/pal_runtimeinformation.c b/src/native/libs/System.Native/pal_runtimeinformation.c index c7b7073..107aff8 100644 --- a/src/native/libs/System.Native/pal_runtimeinformation.c +++ b/src/native/libs/System.Native/pal_runtimeinformation.c @@ -53,52 +53,8 @@ int32_t SystemNative_GetUnixVersion(char* version, int* capacity) return 0; } -/* Returns an int representing the OS Architecture: - 0 - x86 - 1 - x64 - 2 - ARM - 3 - ARM64 - 4 - WASM */ +/* Returns an int representing the OS Architecture. -1 if same as process architecture. */ int32_t SystemNative_GetOSArchitecture() { -#if defined(TARGET_ARM) - return ARCH_ARM; -#elif defined(TARGET_ARM64) - return ARCH_ARM64; -#elif defined(TARGET_AMD64) - return ARCH_X64; -#elif defined(TARGET_X86) - return ARCH_X86; -#elif defined(TARGET_WASM) - return ARCH_WASM; -#elif defined(TARGET_S390X) - return ARCH_S390X; -#else -#error Unidentified Architecture -#endif -} - -/* Returns an int representing the OS Architecture: -0 - x86 -1 - x64 -2 - ARM -3 - ARM64 -4 - WASM */ -int32_t SystemNative_GetProcessArchitecture() -{ -#if defined(TARGET_ARM) - return ARCH_ARM; -#elif defined(TARGET_ARM64) - return ARCH_ARM64; -#elif defined(TARGET_AMD64) - return ARCH_X64; -#elif defined(TARGET_X86) - return ARCH_X86; -#elif defined(TARGET_WASM) - return ARCH_WASM; -#elif defined(TARGET_S390X) - return ARCH_S390X; -#else -#error Unidentified Architecture -#endif + return -1; } diff --git a/src/native/libs/System.Native/pal_runtimeinformation.h b/src/native/libs/System.Native/pal_runtimeinformation.h index ff7e91d..6b13077 100644 --- a/src/native/libs/System.Native/pal_runtimeinformation.h +++ b/src/native/libs/System.Native/pal_runtimeinformation.h @@ -14,8 +14,7 @@ PALEXPORT int32_t SystemNative_GetUnixVersion(char* version, int* capacity); PALEXPORT int32_t SystemNative_GetOSArchitecture(void); -PALEXPORT int32_t SystemNative_GetProcessArchitecture(void); - +// Keep in sync with System.Runtime.InteropServices.Architecture enum enum { ARCH_X86,