Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public sealed class StopComputerCommand : CommandLineCmdletBase
protected override void BeginProcessing()
{
var args = "-P now";
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
if (Platform.IsMacOS)
{
args = "now";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected override void ProcessRecord()
}
}
#else
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
if (Platform.IsLinux)
{
string errorMessage = UnblockFileStrings.LinuxNotSupported;
Exception e = new PlatformNotSupportedException(errorMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static class EntryPoint
public static int Main(string[] args)
{
var currentPath = new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location).Directory.FullName;
var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
var isWindows = Platform.IsWindows;

string platformFolder = isWindows ? WinFolderName : UnixFolderName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,17 +540,17 @@ private static string GetNativeDllSubFolderName(out string ext)
ext = string.Empty;
var processArch = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (Platform.IsWindows)
{
folderName = "win-" + processArch;
ext = ".dll";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
else if (Platform.IsLinux)
{
folderName = "linux-" + processArch;
ext = ".so";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
else if (Platform.IsMacOS)
{
folderName = "osx-x64";
ext = ".dylib";
Expand Down
6 changes: 3 additions & 3 deletions src/System.Management.Automation/CoreCLR/CorePsPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static bool IsLinux
{
get
{
return RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
return OperatingSystem.IsLinux();
}
}

Expand All @@ -33,7 +33,7 @@ public static bool IsMacOS
{
get
{
return RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
return OperatingSystem.IsMacOS();
}
}

Expand All @@ -44,7 +44,7 @@ public static bool IsWindows
{
get
{
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
return OperatingSystem.IsWindows();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,7 @@ protected override ProviderInfo Start(ProviderInfo providerInfo)
#if !UNIX
// The placeholder mode management APIs Rtl(Set|Query)(Process|Thread)PlaceholderCompatibilityMode
// are only supported starting with Windows 10 version 1803 (build 17134)
Version minBuildForPlaceHolderAPIs = new Version(10, 0, 17134, 0);

if (Environment.OSVersion.Version >= minBuildForPlaceHolderAPIs)
if (OperatingSystem.IsWindowsVersionAtLeast(10, 0, 17134, 0))
{
// let's be safe, don't change the PlaceHolderCompatibilityMode if the current one is not what we expect
if (NativeMethods.RtlQueryProcessPlaceholderCompatibilityMode() == NativeMethods.PHCM_DISGUISE_PLACEHOLDER)
Expand Down Expand Up @@ -2724,8 +2722,7 @@ private static bool WinCreateSymbolicLink(string path, string strTargetPath, boo
// The new AllowUnprivilegedCreate is only available on Win10 build 14972 or newer
var flags = isDirectory ? NativeMethods.SymbolicLinkFlags.Directory : NativeMethods.SymbolicLinkFlags.File;

Version minBuildOfDeveloperMode = new Version(10, 0, 14972, 0);
if (Environment.OSVersion.Version >= minBuildOfDeveloperMode)
if (OperatingSystem.IsWindowsVersionAtLeast(10, 0, 14972, 0))
{
flags |= NativeMethods.SymbolicLinkFlags.AllowUnprivilegedCreate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ private void ResolveFromStoreById(ResolutionPurpose purpose, out ErrorRecord err
storeCU.Open(OpenFlags.ReadOnly);
X509Certificate2Collection storeCerts = storeCU.Certificates;

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (Platform.IsWindows)
{
using (var storeLM = new X509Store("my", StoreLocation.LocalMachine))
{
Expand Down
3 changes: 2 additions & 1 deletion src/powershell/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System;
using System.IO;
using System.Management.Automation;
using System.Reflection;
using System.Runtime.InteropServices;

Expand Down Expand Up @@ -89,7 +90,7 @@ private static void AttemptExecPwshLogin(string[] args)
return;
}

bool isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
bool isLinux = Platform.IsLinux;

// The first byte (ASCII char) of the name of this process, used to detect '-' for login
byte procNameFirstByte;
Expand Down
4 changes: 2 additions & 2 deletions test/perf/benchmarks/Engine.ScriptBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public IEnumerable<string> ValuesForScript()
yield return @"[System.IO.Path]::HasExtension('')";

// Test on COM method invocation.
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (Platform.IsWindows)
{
yield return @"$sh=New-Object -ComObject Shell.Application; $sh.Namespace('c:\')";
yield return @"$fs=New-Object -ComObject scripting.filesystemobject; $fs.Drives";
Expand All @@ -54,7 +54,7 @@ public void GlobalSetup()
// believe that there is no need to run many ops in each interation. However, the subsequent runs
// of this method is much faster than the first run, and this causes 'MinIterationTime' warnings
// to our benchmarks and make the benchmark results not reliable.
// Calling this method once in 'GlobalSetup' is a workaround.
// Calling this method once in 'GlobalSetup' is a workaround.
// See https://github.com/dotnet/BenchmarkDotNet/issues/837#issuecomment-828600157
scriptBlock.Invoke();
}
Expand Down