- 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
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'x86'">
<PlatformTarget>x86</PlatformTarget>
+ <DefineConstants>$(DefineConstants);TARGET_X86</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'arm'">
<PlatformTarget>arm</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'x86'">
<PlatformTarget>x86</PlatformTarget>
- <DefineConstants>TARGET_32BIT;$(DefineConstants)</DefineConstants>
+ <DefineConstants>TARGET_32BIT;TARGET_X86;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'arm'">
<PlatformTarget>arm</PlatformTarget>
+++ /dev/null
-// 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();
- }
-}
+++ /dev/null
-// 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
- }
- }
-}
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;
}
}
<data name="Argument_BadResourceScopeVisibilityBits" xml:space="preserve">
<value>Unknown value for the ResourceScope: {0} Too many resource visibility bits may be set.</value>
</data>
- <data name="net_emptystringcall" xml:space="preserve">
- <value>The parameter '{0}' cannot be an empty string.</value>
- </data>
- <data name="Argument_EmptyApplicationName" xml:space="preserve">
- <value>ApplicationId cannot have an empty string for the name.</value>
+ <data name="Argument_EmptyString" xml:space="preserve">
+ <value>The value cannot be an empty string.</value>
</data>
<data name="Argument_FrameworkNameInvalid" xml:space="preserve">
<value> FrameworkName is invalid.</value>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\ExceptionServices\HandleProcessCorruptedStateExceptionsAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\GCSettings.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\AllowReversePInvokeCallsAttribute.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\Architecture.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\ArrayWithOffset.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\BestFitMappingAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\BStrWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\MarshalDirectiveException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\MemoryMarshal.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\NativeMemory.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\OSPlatform.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\UnmanagedCallConvAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\UnmanagedCallersOnlyAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\NativeLibrary.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\PosixSignalRegistration.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\PreserveSigAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\ProgIdAttribute.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\RuntimeInformation.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\RuntimeInformation.ProcessArchitecture.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\SafeArrayRankMismatchException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\SafeArrayTypeMismatchException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\SafeBuffer.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetModuleFileName.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.GetModuleFileName.cs</Link>
</Compile>
+ <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetNativeSystemInfo.cs">
+ <Link>Common\Interop\Windows\Kernel32\Interop.GetNativeSystemInfo.cs</Link>
+ </Compile>
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetOverlappedResult.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.GetOverlappedResult.cs</Link>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\Marshal.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\NativeMemory.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\PosixSignalRegistration.Windows.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\RuntimeInformation.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\StandardOleMarshalObject.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Security\SecureString.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\LowLevelMonitor.Windows.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetHostName.cs">
<Link>Common\Interop\Unix\System.Native\Interop.GetHostName.cs</Link>
</Compile>
+ <Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetOSArchitecture.cs">
+ <Link>Common\Interop\Unix\System.Native\Interop.GetOSArchitecture.cs</Link>
+ </Compile>
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetProcessPath.cs">
<Link>Common\Interop\Unix\System.Native\Interop.GetProcessPath.cs</Link>
</Compile>
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetUnixName.cs">
<Link>Common\Interop\Unix\System.Native\Interop.GetUnixName.cs</Link>
</Compile>
+ <Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetUnixVersion.cs">
+ <Link>Common\Interop\Unix\System.Native\Interop.GetUnixVersion.cs</Link>
+ </Compile>
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetUnixRelease.cs">
<Link>Common\Interop\Unix\System.Native\Interop.GetUnixRelease.cs</Link>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\MemoryFailPoint.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\Marshal.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\NativeMemory.Unix.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\RuntimeInformation.Unix.cs" Condition="'$(TargetsBrowser)' != 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\StandardOleMarshalObject.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Security\SecureString.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\LowLevelMonitor.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Environment.Browser.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\IO\DriveInfoInternal.Browser.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\IO\PersistedFiles.Browser.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\RuntimeInformation.Browser.cs" />
</ItemGroup>
<ItemGroup Condition="'$(UseMinimalGlobalizationData)' == 'true'">
<Compile Include="$(MSBuildThisFileDirectory)System\TimeZoneInfo.MinimalGlobalizationData.cs" />
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));
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;
}
public static string OSDescription => "Browser";
public static Architecture OSArchitecture => Architecture.Wasm;
-
- public static Architecture ProcessArchitecture => Architecture.Wasm;
}
}
--- /dev/null
+// 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
+ }
+}
--- /dev/null
+// 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;
+ }
+ }
+ }
+}
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
{
{
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;
}
}
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)
{
}
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);
--- /dev/null
+// 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))]
+++ /dev/null
-// 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<System.Runtime.InteropServices.OSPlatform>
- {
- 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; }
- }
-}
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
- <Compile Include="System.Runtime.InteropServices.RuntimeInformation.cs" />
+ <Compile Include="System.Runtime.InteropServices.RuntimeInformation.Forwards.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
+++ /dev/null
-<root>
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
- <xsd:element name="root" msdata:IsDataSet="true">
- <xsd:complexType>
- <xsd:choice maxOccurs="unbounded">
- <xsd:element name="metadata">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- <xsd:attribute name="name" use="required" type="xsd:string" />
- <xsd:attribute name="type" type="xsd:string" />
- <xsd:attribute name="mimetype" type="xsd:string" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="assembly">
- <xsd:complexType>
- <xsd:attribute name="alias" type="xsd:string" />
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="resheader">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <resheader name="resmimetype">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="version">
- <value>2.0</value>
- </resheader>
- <resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <data name="Argument_EmptyValue" xml:space="preserve">
- <value>Value cannot be empty.</value>
- </data>
- <data name="PlatformNotSupported_RuntimeInformation" xml:space="preserve">
- <value>RuntimeInformation is not supported for Portable Class Libraries.</value>
- </data>
-</root>
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <RootNamespace>System.Runtime.InteropServices</RootNamespace>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
+ <TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
<Nullable>enable</Nullable>
- <TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
- <Compile Include="System\Runtime\InteropServices\RuntimeInformation\RuntimeInformation.cs" />
- <Compile Include="System\Runtime\InteropServices\RuntimeInformation\Architecture.cs" />
- <Compile Include="System\Runtime\InteropServices\RuntimeInformation\OSPlatform.cs" />
- </ItemGroup>
- <ItemGroup Condition="'$(TargetsBrowser)' == 'true'">
- <Compile Include="System\Runtime\InteropServices\RuntimeInformation\RuntimeInformation.Browser.cs" />
- </ItemGroup>
- <ItemGroup Condition="'$(TargetsUnix)' == 'true'">
- <Compile Include="System\Runtime\InteropServices\RuntimeInformation\RuntimeInformation.Unix.cs" />
- <Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetUnixVersion.cs"
- Link="Common\Interop\Unix\System.Native\Interop.GetUnixVersion.cs" />
- <Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetOSArchitecture.cs"
- Link="Common\Interop\Unix\System.Native\Interop.GetOSArchitecture.cs" />
- <Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetProcessArchitecture.cs"
- Link="Common\Interop\Unix\System.Native\Interop.GetProcessArchitecture.cs" />
- <Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.ProcessorArchitecture.cs"
- Link="Common\Interop\Unix\System.Native\Interop.ProcessorArchitecture.cs" />
- <Compile Include="$(CommonPath)Interop\Unix\Interop.Libraries.cs"
- Link="Common\Interop\Unix\Interop.Libraries.cs" />
- </ItemGroup>
- <ItemGroup Condition="'$(TargetsWindows)' == 'true'">
- <Compile Include="System\Runtime\InteropServices\RuntimeInformation\RuntimeInformation.Windows.cs" />
- <Compile Include="$(CommonPath)Interop\Windows\Interop.Libraries.cs"
- Link="Common\Interop\Windows\Interop.Libraries.cs" />
- <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetNativeSystemInfo.cs"
- Link="Common\Interop\Windows\Kernel32\Interop.GetNativeSystemInfo.cs" />
- <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.SYSTEM_INFO.cs"
- Link="Common\Interop\Windows\Kernel32\Interop.SYSTEM_INFO.cs" />
- <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetSystemInfo.cs"
- Link="Common\Interop\Windows\Kernel32\Interop.GetSystemInfo.cs" />
- </ItemGroup>
- <ItemGroup>
- <Reference Include="System.Memory" />
- <Reference Include="System.Reflection" />
- <Reference Include="System.Reflection.Extensions" />
- <Reference Include="System.Memory" />
<Reference Include="System.Runtime" />
- <Reference Include="System.Runtime.CompilerServices.Unsafe" />
- <Reference Include="System.Runtime.InteropServices" />
- <Reference Include="System.Threading" />
</ItemGroup>
</Project>
+++ /dev/null
-// 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;
- }
- }
- }
-}
}
namespace System.Runtime.InteropServices
{
+ public enum Architecture
+ {
+ X86 = 0,
+ X64 = 1,
+ Arm = 2,
+ Arm64 = 3,
+ Wasm = 4,
+ S390x = 5,
+ }
public enum CharSet
{
None = 1,
Explicit = 2,
Auto = 3,
}
+ public readonly partial struct OSPlatform : System.IEquatable<System.Runtime.InteropServices.OSPlatform>
+ {
+ 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)) { }
<data name="ArgumentOutOfRange_NeedPosNum" xml:space="preserve">
<value>Positive number required.</value>
</data>
- <data name="Argument_CannotBeNullOrEmpty" xml:space="preserve">
- <value>Argument cannot be null or empty.</value>
- </data>
<data name="Argument_EmptyName" xml:space="preserve">
<value>Empty name is not legal.</value>
</data>
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<EnableDefaultItems>false</EnableDefaultItems>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'x86'">
<PlatformTarget>x86</PlatformTarget>
+ <DefineConstants>$(DefineConstants);TARGET_X86</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'arm'">
<PlatformTarget>arm</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'wasm'">
<PlatformTarget>AnyCPU</PlatformTarget>
+ <DefineConstants>$(DefineConstants);TARGET_WASM</DefineConstants>
</PropertyGroup>
<!-- Configuration specific properties -->
DllImportEntry(SystemNative_GetUnixRelease)
DllImportEntry(SystemNative_GetUnixVersion)
DllImportEntry(SystemNative_GetOSArchitecture)
- DllImportEntry(SystemNative_GetProcessArchitecture)
DllImportEntry(SystemNative_SearchPath)
DllImportEntry(SystemNative_SearchPath_TempDirectory)
DllImportEntry(SystemNative_RegisterForSigChld)
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;
}
PALEXPORT int32_t SystemNative_GetOSArchitecture(void);
-PALEXPORT int32_t SystemNative_GetProcessArchitecture(void);
-
+// Keep in sync with System.Runtime.InteropServices.Architecture enum
enum
{
ARCH_X86,