* use new OperatingSystem APIs in test projects that target NetCoreAppCurrent only
* use `||` instead of `|`
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Runtime.InteropServices;
using System.Security.Authentication;
namespace System.Net.Test.Common
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
-using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Xunit;
yield return MkConsoleKeyInfo('\x01', ConsoleKey.A, ConsoleModifiers.Control | ConsoleModifiers.Alt);
yield return MkConsoleKeyInfo('\r', ConsoleKey.Enter, (ConsoleModifiers)0);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
// windows will report '\n' as 'Ctrl+Enter', which is typically not picked up by Unix terminals
yield return MkConsoleKeyInfo('\n', ConsoleKey.Enter, ConsoleModifiers.Control);
using System;
using System.Diagnostics;
using System.IO;
-using System.Runtime.InteropServices;
using Microsoft.DotNet.RemoteExecutor;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
[OuterLoop] // clears the screen, not very inner-loop friendly
public static void Clear_Invoke_Success()
{
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || (!Console.IsInputRedirected && !Console.IsOutputRedirected))
+ if (!OperatingSystem.IsWindows() || (!Console.IsInputRedirected && !Console.IsOutputRedirected))
{
// Nothing to verify; just run the code.
Console.Clear();
[PlatformSpecific(~TestPlatforms.Browser)]
public static void SetCursorPosition_Invoke_Success()
{
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || (!Console.IsInputRedirected && !Console.IsOutputRedirected))
+ if (!OperatingSystem.IsWindows() || (!Console.IsInputRedirected && !Console.IsOutputRedirected))
{
int origLeft = Console.CursorLeft;
int origTop = Console.CursorTop;
Assert.Equal(origTop, Console.CursorTop);
Assert.Equal(origTuple, Console.GetCursorPosition());
}
- else if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ else if (!OperatingSystem.IsWindows())
{
Assert.Equal(0, Console.CursorLeft);
Assert.Equal(0, Console.CursorTop);
Console.CursorLeft = origLeft;
Assert.Equal(origLeft, Console.CursorLeft);
}
- else if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ else if (!OperatingSystem.IsWindows())
{
Assert.Equal(0, Console.CursorLeft);
}
Console.CursorTop = origTop;
Assert.Equal(origTop, Console.CursorTop);
}
- else if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ else if (!OperatingSystem.IsWindows())
{
Assert.Equal(0, Console.CursorTop);
}
// The .NET Foundation licenses this file to you under the MIT license.
using System.IO;
-using System.Runtime.InteropServices;
using System.Text;
using Microsoft.DotNet.RemoteExecutor;
using Xunit;
Assert.True(p.WaitForExit(WaitInMS));
};
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (!OperatingSystem.IsWindows())
{
run(Encoding.UTF8.CodePage);
return;
environment.Add("NewKey2", "NewValue2");
Assert.True(environment.ContainsKey("NewKey"));
- Assert.Equal(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), environment.ContainsKey("newkey"));
+ Assert.Equal(OperatingSystem.IsWindows(), environment.ContainsKey("newkey"));
Assert.False(environment.ContainsKey("NewKey99"));
//Iterating
//Contains
Assert.True(environment.Contains(new KeyValuePair<string, string>("NewKey", "NewValue")));
- Assert.Equal(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), environment.Contains(new KeyValuePair<string, string>("nEwKeY", "NewValue")));
+ Assert.Equal(OperatingSystem.IsWindows(), environment.Contains(new KeyValuePair<string, string>("nEwKeY", "NewValue")));
Assert.False(environment.Contains(new KeyValuePair<string, string>("NewKey99", "NewValue99")));
//Exception not thrown with invalid key
Assert.True(environment.TryGetValue("NewKey", out stringout));
Assert.Equal("NewValue", stringout);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
Assert.True(environment.TryGetValue("NeWkEy", out stringout));
Assert.Equal("NewValue", stringout);
Assert.Throws<KeyNotFoundException>(() => environment["1bB"]);
Assert.True(environment.Contains(new KeyValuePair<string, string>("NewKey2", "NewValue2OverriddenAgain")));
- Assert.Equal(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), environment.Contains(new KeyValuePair<string, string>("NEWKeY2", "NewValue2OverriddenAgain")));
+ Assert.Equal(OperatingSystem.IsWindows(), environment.Contains(new KeyValuePair<string, string>("NEWKeY2", "NewValue2OverriddenAgain")));
Assert.False(environment.Contains(new KeyValuePair<string, string>("NewKey2", "newvalue2Overriddenagain")));
Assert.False(environment.Contains(new KeyValuePair<string, string>("newkey2", "newvalue2Overriddenagain")));
[OuterLoop]
public void ProcessStart_UseShellExecute_OnUnix_OpenMissingFile_DoesNotThrow()
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) &&
+ if (OperatingSystem.IsLinux() &&
s_allowedProgramsToRun.FirstOrDefault(program => IsProgramInstalled(program)) == null)
{
return;
File.WriteAllText(fileToOpen, $"{nameof(ProcessStart_UseShellExecute_OnUnix_SuccessWhenProgramInstalled)}");
}
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || programToOpen != null)
+ if (OperatingSystem.IsMacOS() || programToOpen != null)
{
using (var px = Process.Start(new ProcessStartInfo { UseShellExecute = true, FileName = fileToOpen }))
{
Assert.NotNull(px);
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) // on OSX, process name is dotnet for some reason. Refer to https://github.com/dotnet/runtime/issues/23525
+ if (!OperatingSystem.IsMacOS()) // on OSX, process name is dotnet for some reason. Refer to https://github.com/dotnet/runtime/issues/23525
{
Assert.Equal(programToOpen, px.ProcessName);
}
// If this test runs as the user, we expect to be able to match the user groups exactly.
// Except on OSX, where getgrouplist may return a list of groups truncated to NGROUPS_MAX.
bool checkGroupsExact = userId == geteuid().ToString() &&
- !RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
+ !OperatingSystem.IsMacOS();
// Start as username
var invokeOptions = new RemoteInvokeOptions();
// On systems with a low value of NGROUPS_MAX (e.g 16 on OSX), the groups may be truncated.
// On Linux NGROUPS_MAX is 65536, so we expect to see every group.
- bool checkGroupsExact = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
+ bool checkGroupsExact = OperatingSystem.IsLinux();
// Start as username
var invokeOptions = new RemoteInvokeOptions();
using System.IO.Pipes;
using System.Linq;
using System.Net;
-using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using System.Threading;
private void AssertNonZeroWindowsZeroUnix(long value)
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
Assert.NotEqual(0, value);
}
private void AssertNonZeroAllZeroDarwin(long value)
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
Assert.Equal(0, value);
}
Assert.NotEqual(Environment.ProcessId, _process.Id);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
Assert.Equal(_process.Id, Interop.GetProcessId(_process.SafeHandle));
}
Assert.InRange((long)p.MinWorkingSet, 0, long.MaxValue);
}
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) {
+ if (OperatingSystem.IsMacOS() || OperatingSystem.IsFreeBSD()) {
return; // doesn't support getting/setting working set for other processes
}
long curValue = (long)_process.MaxWorkingSet;
Assert.InRange(curValue, 0, long.MaxValue);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
try
{
Assert.InRange((long)p.MinWorkingSet, 0, long.MaxValue);
}
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) {
+ if (OperatingSystem.IsMacOS() || OperatingSystem.IsFreeBSD()) {
return; // doesn't support getting/setting working set for other processes
}
long curValue = (long)_process.MinWorkingSet;
Assert.InRange(curValue, 0, long.MaxValue);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
try
{
{
CreateDefaultProcess();
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
// resident memory can be 0 on OSX.
Assert.InRange(_process.WorkingSet64, 0, long.MaxValue);
{
CreateDefaultProcess();
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
// resident memory can be 0 on OSX.
#pragma warning disable 0618
// The .NET Foundation licenses this file to you under the MIT license.
using System.ComponentModel;
-using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.DotNet.RemoteExecutor;
using Xunit;
ProcessThread thread = _process.Threads[0];
ThreadPriorityLevel level = ThreadPriorityLevel.Normal;
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
Assert.Throws<PlatformNotSupportedException>(() => thread.PriorityLevel);
}
// The .NET Foundation licenses this file to you under the MIT license.
using System.ComponentModel;
-using System.Runtime.InteropServices;
using System.Threading;
using System.Linq;
using Microsoft.DotNet.RemoteExecutor;
// On OSX, thread id is a 64bit unsigned value. We truncate the ulong to int
// due to .NET API surface area. Hence, on overflow id can be negative while
// casting the ulong to int.
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (!OperatingSystem.IsMacOS())
{
Assert.InRange(thread.Id, 0, int.MaxValue);
}
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
-using System.Runtime.InteropServices;
using Xunit;
namespace System.Globalization.Tests
if (ex == null)
{
// Windows and OSX always throw exception. some versions of Linux succeed and others throw exception
- Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
- Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.OSX));
+ Assert.False(OperatingSystem.IsWindows());
+ Assert.False(OperatingSystem.IsMacOS());
Assert.Equal(".", result);
}
else
yield return new object[] { "\u0061\u0062\u0063.\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067.\u30D1\u30D5\u30A3\u30FC\u0064\u0065\u30EB\u30F3\u30D0", 3, 9, typeof(ArgumentException) };
yield return new object[] { "\u0061\u0062\u0063.\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067.\u30D1\u30D5\u30A3\u30FC\u0064\u0065\u30EB\u30F3\u30D0", 11, 10, typeof(ArgumentException) };
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // expected platform differences, see https://github.com/dotnet/runtime/issues/17190
+ if (!OperatingSystem.IsWindows()) // expected platform differences, see https://github.com/dotnet/runtime/issues/17190
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
yield return new object[] { ".", 0, 1, typeof(ArgumentException) };
}
WatcherChangeTypes expected = 0;
if (filter == NotifyFilters.Attributes)
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && ((filter & LinuxFiltersForAttribute) > 0))
+ else if (OperatingSystem.IsLinux() && ((filter & LinuxFiltersForAttribute) > 0))
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & OSXFiltersForModify) > 0))
+ else if (OperatingSystem.IsMacOS() && ((filter & OSXFiltersForModify) > 0))
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & NotifyFilters.Security) > 0))
+ else if (OperatingSystem.IsMacOS() && ((filter & NotifyFilters.Security) > 0))
expected |= WatcherChangeTypes.Changed; // Attribute change on OSX is a ChangeOwner operation which passes the Security NotifyFilter.
ExpectEvent(watcher, expected, action, cleanup, dir.Path);
}
WatcherChangeTypes expected = 0;
if (filter == NotifyFilters.CreationTime)
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && ((filter & LinuxFiltersForAttribute) > 0))
+ else if (OperatingSystem.IsLinux() && ((filter & LinuxFiltersForAttribute) > 0))
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & OSXFiltersForModify) > 0))
+ else if (OperatingSystem.IsMacOS() && ((filter & OSXFiltersForModify) > 0))
expected |= WatcherChangeTypes.Changed;
ExpectEvent(watcher, expected, action, expectedPath: dir.Path);
WatcherChangeTypes expected = 0;
if (filter == NotifyFilters.LastAccess)
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && ((filter & LinuxFiltersForAttribute) > 0))
+ else if (OperatingSystem.IsLinux() && ((filter & LinuxFiltersForAttribute) > 0))
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & OSXFiltersForModify) > 0))
+ else if (OperatingSystem.IsMacOS() && ((filter & OSXFiltersForModify) > 0))
expected |= WatcherChangeTypes.Changed;
ExpectEvent(watcher, expected, action, expectedPath: dir.Path);
WatcherChangeTypes expected = 0;
if (filter == NotifyFilters.LastWrite)
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && ((filter & LinuxFiltersForAttribute) > 0))
+ else if (OperatingSystem.IsLinux() && ((filter & LinuxFiltersForAttribute) > 0))
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & OSXFiltersForModify) > 0))
+ else if (OperatingSystem.IsMacOS() && ((filter & OSXFiltersForModify) > 0))
expected |= WatcherChangeTypes.Changed;
ExpectEvent(watcher, expected, action, expectedPath: dir.Path);
WatcherChangeTypes expected = 0;
if ((filter & NotifyFilters.LastWrite) > 0)
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && ((filter & LinuxFiltersForAttribute) > 0))
+ else if (OperatingSystem.IsLinux() && ((filter & LinuxFiltersForAttribute) > 0))
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & OSXFiltersForModify) > 0))
+ else if (OperatingSystem.IsMacOS() && ((filter & OSXFiltersForModify) > 0))
expected |= WatcherChangeTypes.Changed;
ExpectEvent(watcher, expected, action, expectedPath: dir.Path);
}
WatcherChangeTypes expected = 0;
if (filter == NotifyFilters.Attributes)
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && ((filter & LinuxFiltersForAttribute) > 0))
+ else if (OperatingSystem.IsLinux() && ((filter & LinuxFiltersForAttribute) > 0))
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & OSXFiltersForModify) > 0))
+ else if (OperatingSystem.IsMacOS() && ((filter & OSXFiltersForModify) > 0))
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & NotifyFilters.Security) > 0))
+ else if (OperatingSystem.IsMacOS() && ((filter & NotifyFilters.Security) > 0))
expected |= WatcherChangeTypes.Changed; // Attribute change on OSX is a ChangeOwner operation which passes the Security NotifyFilter.
ExpectEvent(watcher, expected, action, cleanup, file.Path);
WatcherChangeTypes expected = 0;
if (filter == NotifyFilters.CreationTime)
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && ((filter & LinuxFiltersForAttribute) > 0))
+ else if (OperatingSystem.IsLinux() && ((filter & LinuxFiltersForAttribute) > 0))
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & OSXFiltersForModify) > 0))
+ else if (OperatingSystem.IsMacOS() && ((filter & OSXFiltersForModify) > 0))
expected |= WatcherChangeTypes.Changed;
ExpectEvent(watcher, expected, action, expectedPath: file.Path);
WatcherChangeTypes expected = 0;
if (filter == NotifyFilters.LastAccess)
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && ((filter & LinuxFiltersForAttribute) > 0))
+ else if (OperatingSystem.IsLinux() && ((filter & LinuxFiltersForAttribute) > 0))
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & OSXFiltersForModify) > 0))
+ else if (OperatingSystem.IsMacOS() && ((filter & OSXFiltersForModify) > 0))
expected |= WatcherChangeTypes.Changed;
ExpectEvent(watcher, expected, action, expectedPath: file.Path);
}
WatcherChangeTypes expected = 0;
if (filter == NotifyFilters.LastWrite)
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && ((filter & LinuxFiltersForAttribute) > 0))
+ else if (OperatingSystem.IsLinux() && ((filter & LinuxFiltersForAttribute) > 0))
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & OSXFiltersForModify) > 0))
+ else if (OperatingSystem.IsMacOS() && ((filter & OSXFiltersForModify) > 0))
expected |= WatcherChangeTypes.Changed;
ExpectEvent(watcher, expected, action, expectedPath: file.Path);
}
WatcherChangeTypes expected = 0;
if (filter == NotifyFilters.Size || filter == NotifyFilters.LastWrite)
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && ((filter & LinuxFiltersForModify) > 0))
+ else if (OperatingSystem.IsLinux() && ((filter & LinuxFiltersForModify) > 0))
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & OSXFiltersForModify) > 0))
+ else if (OperatingSystem.IsMacOS() && ((filter & OSXFiltersForModify) > 0))
expected |= WatcherChangeTypes.Changed;
else if (PlatformDetection.IsWindows7 && filter == NotifyFilters.Attributes) // win7 FSW Size change passes the Attribute filter
expected |= WatcherChangeTypes.Changed;
WatcherChangeTypes expected = 0;
if (((filter & NotifyFilters.Size) > 0) || ((filter & NotifyFilters.LastWrite) > 0))
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && ((filter & LinuxFiltersForModify) > 0))
+ else if (OperatingSystem.IsLinux() && ((filter & LinuxFiltersForModify) > 0))
expected |= WatcherChangeTypes.Changed;
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & OSXFiltersForModify) > 0))
+ else if (OperatingSystem.IsMacOS() && ((filter & OSXFiltersForModify) > 0))
expected |= WatcherChangeTypes.Changed;
else if (PlatformDetection.IsWindows7 && ((filter & NotifyFilters.Attributes) > 0)) // win7 FSW Size change passes the Attribute filter
expected |= WatcherChangeTypes.Changed;
using System.Collections.ObjectModel;
using System.Linq;
-using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
watcher.Path = currentDir;
Assert.Equal(currentDir, watcher.Path);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || // expect no change for OrdinalIgnoreCase-equal strings
- RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsWindows() || // expect no change for OrdinalIgnoreCase-equal strings
+ OperatingSystem.IsMacOS())
{
watcher.Path = currentDir.ToUpperInvariant();
Assert.Equal(currentDir, watcher.Path);
using System.Collections.Generic;
using System.Diagnostics;
-using System.Runtime.InteropServices;
using System.Threading;
using Xunit;
using Xunit.Sdk;
public static bool CreateSymLink(string targetPath, string linkPath, bool isDirectory)
{
Process symLinkProcess = new Process();
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
symLinkProcess.StartInfo.FileName = "cmd";
symLinkProcess.StartInfo.Arguments = string.Format("/c mklink{0} \"{1}\" \"{2}\"", isDirectory ? " /D" : "", Path.GetFullPath(linkPath), Path.GetFullPath(targetPath));
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Runtime.InteropServices;
using System.Text;
using Xunit;
using Microsoft.DotNet.XUnitExtensions;
{
public class Directory_Delete_str : FileSystemTest
{
- static bool IsBindMountSupported => RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && !PlatformDetection.IsInContainer;
+ static bool IsBindMountSupported => OperatingSystem.IsLinux() && !PlatformDetection.IsInContainer;
#region Utilities
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq;
-using System.Runtime.InteropServices;
using Xunit;
namespace System.IO.Tests
// considered a file (since it's broken and we don't know what it'll eventually point to).
Directory.Delete(path);
Assert.False(Directory.Exists(path), "path should now not exist");
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
Assert.True(Directory.Exists(linkPath), "linkPath should still exist as a directory");
Assert.False(File.Exists(linkPath), "linkPath should not be a file");
try
{
Directory.Delete(linkPath);
- Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Should only succeed on Windows");
+ Assert.True(OperatingSystem.IsWindows(), "Should only succeed on Windows");
}
catch (IOException)
{
- Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Should only fail on Unix");
+ Assert.False(OperatingSystem.IsWindows(), "Should only fail on Unix");
File.Delete(linkPath);
}
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq;
-using System.Runtime.InteropServices;
using Xunit;
namespace System.IO.Tests
}
targetDir.Delete(recursive: true);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
Assert.Equal(1, GetEntries(containingFolder.FullName).Count());
Assert.Equal(0, Directory.GetFiles(containingFolder.FullName).Count());
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
-using System.Runtime.InteropServices;
using Microsoft.DotNet.RemoteExecutor;
using Xunit;
// On OSX, the temp directory /tmp/ is a symlink to /private/tmp, so setting the current
// directory to a symlinked path will result in GetCurrentDirectory returning the absolute
// path that followed the symlink.
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (!OperatingSystem.IsMacOS())
{
Assert.Equal(TestDirectory, Directory.GetCurrentDirectory());
}
// Set Current Directory to symlink
Directory.SetCurrentDirectory(linkPath);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
Assert.Equal(linkPath, Directory.GetCurrentDirectory());
}
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ else if (OperatingSystem.IsMacOS())
{
Assert.Equal("/private" + path, Directory.GetCurrentDirectory());
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Runtime.InteropServices;
using Xunit;
namespace System.IO.Tests
pathFI.Refresh();
Assert.False(pathFI.Exists, "path should now not exist");
linkPathFI.Refresh();
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
Assert.True(linkPathFI.Exists, "linkPath directory should still exist");
Assert.False(File.Exists(linkPath), "linkPath file should not exist");
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Runtime.InteropServices;
using Xunit;
using Microsoft.DotNet.XUnitExtensions;
{
public class File_Delete : FileSystemTest
{
- static bool IsBindMountSupported => RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && !PlatformDetection.IsInContainer;
+ static bool IsBindMountSupported => OperatingSystem.IsLinux() && !PlatformDetection.IsInContainer;
protected virtual void Delete(string path)
{
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Xunit;
try
{
// Operation succeeds when being run by the Unix superuser
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0)
+ if (!OperatingSystem.IsWindows() && geteuid() == 0)
{
File.WriteAllBytes(path, Encoding.UTF8.GetBytes("text"));
Assert.Equal(Encoding.UTF8.GetBytes("text"), File.ReadAllBytes(path));
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
try
{
// Operation succeeds when being run by the Unix superuser
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0)
+ if (!OperatingSystem.IsWindows() && geteuid() == 0)
{
await File.WriteAllBytesAsync(path, Encoding.UTF8.GetBytes("text"));
Assert.Equal(Encoding.UTF8.GetBytes("text"), await File.ReadAllBytesAsync(path));
using System.Collections.Generic;
using System.Linq;
-using System.Runtime.InteropServices;
using System.Text;
using Xunit;
try
{
// Operation succeeds when being run by the Unix superuser
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0)
+ if (!OperatingSystem.IsWindows() && geteuid() == 0)
{
Write(path, new string[] { "text" });
Assert.Equal(new string[] { "text" }, Read(path));
try
{
// Operation succeeds when being run by the Unix superuser
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0)
+ if (!OperatingSystem.IsWindows() && geteuid() == 0)
{
Write(path, new string[] { "text" });
Assert.Equal(new string[] { "text" }, Read(path));
using System.Collections.Generic;
using System.Linq;
-using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
try
{
// Operation succeeds when being run by the Unix superuser
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0)
+ if (!OperatingSystem.IsWindows() && geteuid() == 0)
{
await WriteAsync(path, new string[] { "text" });
Assert.Equal(new string[] { "text" }, await ReadAsync(path));
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Runtime.InteropServices;
using System.Text;
using Xunit;
try
{
// Operation succeeds when being run by the Unix superuser
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0)
+ if (!OperatingSystem.IsWindows() && geteuid() == 0)
{
Write(path, "text");
Assert.Equal("text", Read(path));
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq;
-using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
try
{
// Operation succeeds when being run by the Unix superuser
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0)
+ if (!OperatingSystem.IsWindows() && geteuid() == 0)
{
await WriteAsync(path, "text");
Assert.Equal("text", await ReadAsync(path));
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Runtime.InteropServices;
using Xunit;
namespace System.IO.Tests
Assert.Equal(FileSize, info.Length);
var linkInfo = new FileInfo(linkPath);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
// On Windows, symlinks have length 0.
Assert.Equal(0, linkInfo.Length);
using Microsoft.Win32.SafeHandles;
using System;
using System.IO;
-using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Xunit;
fs.WriteByte(0);
fsr.Position++;
- if (useAsync && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // Async I/O behaviors differ due to kernel-based implementation on Windows
+ if (useAsync && OperatingSystem.IsWindows()) // Async I/O behaviors differ due to kernel-based implementation on Windows
{
Assert.Throws<IOException>(() => FSAssert.CompletesSynchronously(fs.ReadAsync(new byte[1], 0, 1)));
}
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
-using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
{
foreach (bool useAsync in new[] { true, false })
{
- if (useAsync && !RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (useAsync && !OperatingSystem.IsWindows())
{
// We don't have a special async I/O implementation in FileStream on Unix.
continue;
{
// For inner loop, just test one case
return ManyConcurrentWriteAsyncs_OuterLoop(
- useAsync: RuntimeInformation.IsOSPlatform(OSPlatform.Windows),
+ useAsync: OperatingSystem.IsWindows(),
presize: false,
exposeHandle: false,
cancelable: true,
using System;
using System.IO;
-using System.Runtime.InteropServices;
using Xunit;
namespace System.IO.Tests
{
Assert.True(File.Exists(fileName));
File.Delete(fileName);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
// Prior to 1903 Windows would not delete the filename until the last file handle is closed.
Assert.Equal(PlatformDetection.IsWindows10Version1903OrGreater, !File.Exists(fileName));
using (FileStream fs = CreateFileStream(fileName, FileMode.Open, FileAccess.ReadWrite, FileShare.Delete))
{
File.Delete(fileName);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
// Prior to 1903 Windows would not delete the filename until the last file handle is closed.
Assert.Equal(PlatformDetection.IsWindows10Version1903OrGreater, !File.Exists(fileName));
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Runtime.InteropServices;
internal static class IOInputs
{
- public static bool SupportsSettingCreationTime { get { return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); } }
- public static bool SupportsGettingCreationTime { get { return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) | RuntimeInformation.IsOSPlatform(OSPlatform.OSX); } }
+ public static bool SupportsSettingCreationTime => OperatingSystem.IsWindows();
+ public static bool SupportsGettingCreationTime => OperatingSystem.IsWindows() || OperatingSystem.IsMacOS();
// Max path length (minus trailing \0). Unix values vary system to system; just using really long values here likely to be more than on the average system.
- public static readonly int MaxPath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? 259 : 10000;
+ public static readonly int MaxPath = OperatingSystem.IsWindows() ? 259 : 10000;
// Windows specific, this is the maximum length that can be passed using extended syntax. Does not include the trailing \0.
public static readonly int MaxExtendedPath = short.MaxValue - 1;
// Same as MaxPath on Unix
- public static readonly int MaxLongPath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? MaxExtendedPath : MaxPath;
+ public static readonly int MaxLongPath = OperatingSystem.IsWindows() ? MaxExtendedPath : MaxPath;
// Windows specific, this is the maximum length that can be passed to APIs taking directory names, such as Directory.CreateDirectory & Directory.Move.
// Does not include the trailing \0.
public static bool CreateSymbolicLink(string linkPath, string targetPath, bool isDirectory)
{
Process symLinkProcess = new Process();
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
symLinkProcess.StartInfo.FileName = "cmd";
symLinkProcess.StartInfo.Arguments = string.Format("/c mklink{0} \"{1}\" \"{2}\"", isDirectory ? " /D" : "", linkPath, targetPath);
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
-using System.Runtime.InteropServices;
using Xunit;
namespace System.IO.IsolatedStorage
};
// https://github.com/dotnet/runtime/issues/2092
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
+ if (OperatingSystem.IsWindows()
&& !PlatformDetection.IsInAppContainer)
{
validScopes.Add(PresetScopes.MachineStoreForApplication);
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
-using System.Runtime.InteropServices;
using System.Text;
namespace System.IO.IsolatedStorage
// https://github.com/dotnet/runtime/issues/2092
// https://github.com/dotnet/runtime/issues/21742
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
+ if (OperatingSystem.IsWindows()
&& !PlatformDetection.IsInAppContainer)
{
s_roots.Add(Helper.GetDataDirectory(IsolatedStorageScope.Machine));
using Microsoft.Win32.SafeHandles;
using System.Collections.Generic;
-using System.Runtime.InteropServices;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
public void WriteToReadOnlyFile_ReadWrite(MemoryMappedFileAccess access)
{
WriteToReadOnlyFile(access, access == MemoryMappedFileAccess.Read ||
- (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser));
+ (!OperatingSystem.IsWindows() && PlatformDetection.IsSuperUser));
}
[Fact]
public void WriteToReadOnlyFile_CopyOnWrite()
{
- WriteToReadOnlyFile(MemoryMappedFileAccess.CopyOnWrite, (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser));
+ WriteToReadOnlyFile(MemoryMappedFileAccess.CopyOnWrite, (!OperatingSystem.IsWindows() && PlatformDetection.IsSuperUser));
}
/// <summary>
const int _SC_PAGESIZE_NetBSD = 28;
const int _SC_PAGESIZE_OSX = 29;
pageSize = sysconf(
- RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? _SC_PAGESIZE_OSX :
- RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")) ? _SC_PAGESIZE_FreeBSD :
+ OperatingSystem.IsMacOS() ? _SC_PAGESIZE_OSX :
+ OperatingSystem.IsFreeBSD() ? _SC_PAGESIZE_FreeBSD :
RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD")) ? _SC_PAGESIZE_NetBSD :
_SC_PAGESIZE_Linux);
Assert.InRange(pageSize, 1, int.MaxValue);
/// <summary>Asserts that the handle's inheritability matches the specified value.</summary>
protected static void AssertInheritability(SafeHandle handle, HandleInheritability inheritability)
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
uint flags;
Assert.True(GetHandleInformation(handle.DangerousGetHandle(), out flags));
using System.Collections.Generic;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
using Xunit;
namespace System.IO.MemoryMappedFiles.Tests
public abstract partial class MemoryMappedFilesTestBase : FileCleanupTestBase
{
/// <summary>Gets whether named maps are supported by the current platform.</summary>
- protected static bool MapNamesSupported { get { return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); } }
+ protected static bool MapNamesSupported => OperatingSystem.IsWindows();
/// <summary>Creates a map name guaranteed to be unique.</summary>
protected static string CreateUniqueMapName() { return Guid.NewGuid().ToString("N"); }
using Microsoft.Win32.SafeHandles;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
}
catch (UnauthorizedAccessException)
{
- if ((RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || PlatformDetection.IsInContainer) &&
+ if ((OperatingSystem.IsMacOS() || PlatformDetection.IsInContainer) &&
(viewAccess == MemoryMappedFileAccess.ReadExecute || viewAccess == MemoryMappedFileAccess.ReadWriteExecute))
{
// Containers and OSX with SIP enabled do not have execute permissions by default.
using (MemoryMappedViewAccessor acc = mmf.CreateViewAccessor(MapLength, 0))
{
Assert.Equal(
- RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? MapLength : 0,
+ OperatingSystem.IsWindows() ? MapLength : 0,
acc.PointerOffset);
}
}
using Microsoft.Win32.SafeHandles;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
}
catch (UnauthorizedAccessException)
{
- if ((RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || PlatformDetection.IsInContainer) &&
+ if ((OperatingSystem.IsMacOS() || PlatformDetection.IsInContainer) &&
(viewAccess == MemoryMappedFileAccess.ReadExecute || viewAccess == MemoryMappedFileAccess.ReadWriteExecute))
{
// Containers and OSX with SIP enabled do not have execute permissions by default.
using (MemoryMappedViewStream s = mmf.CreateViewStream(MapLength, 0))
{
Assert.Equal(
- RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? MapLength : 0,
+ OperatingSystem.IsWindows() ? MapLength : 0,
s.PointerOffset);
}
}
using System.Collections.Generic;
using System.Linq;
-using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
Task<int> clientTask = client.ReadAsync(received1, 0, received1.Length);
using (NamedPipeServerStream server = new NamedPipeServerStream(PipeDirection.Out, false, true, serverBase.SafePipeHandle))
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
Assert.Equal(1, client.NumberOfServerInstances);
}
{
using (NamedPipeClientStream client = new NamedPipeClientStream(PipeDirection.In, false, true, pair.clientStream.SafePipeHandle))
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
Assert.Equal(1, client.NumberOfServerInstances);
}
NamedPipeServerStream server = pair.serverStream;
var ctx = new CancellationTokenSource();
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // cancellation token after the operation has been initiated
+ if (OperatingSystem.IsWindows()) // cancellation token after the operation has been initiated
{
Task serverWaitTimeout = server.WaitForConnectionAsync(ctx.Token);
ctx.Cancel();
if (!pair.writeToServer)
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // writes on Unix may still succeed after other end disconnects, due to socket being used
+ if (OperatingSystem.IsWindows()) // writes on Unix may still succeed after other end disconnects, due to socket being used
{
// Pipe is broken
Assert.Throws<IOException>(() => client.Write(buffer, 0, buffer.Length));
Assert.Equal(0, client.Read(buffer, 0, buffer.Length));
Assert.Equal(-1, client.ReadByte());
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // NumberOfServerInstances not supported on Unix
+ if (!OperatingSystem.IsWindows()) // NumberOfServerInstances not supported on Unix
{
Assert.Throws<PlatformNotSupportedException>(() => client.NumberOfServerInstances);
}
if (server.CanWrite)
{
var ctx1 = new CancellationTokenSource();
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // On Unix WriteAsync's aren't cancelable once initiated
+ if (OperatingSystem.IsWindows()) // On Unix WriteAsync's aren't cancelable once initiated
{
Task serverWriteToken = server.WriteAsync(buffer, 0, buffer.Length, ctx1.Token);
ctx1.Cancel();
if (client.CanWrite)
{
var ctx1 = new CancellationTokenSource();
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // On Unix WriteAsync's aren't cancelable once initiated
+ if (OperatingSystem.IsWindows()) // On Unix WriteAsync's aren't cancelable once initiated
{
Task serverWriteToken = client.WriteAsync(buffer, 0, buffer.Length, ctx1.Token);
ctx1.Cancel();
using System.Collections.Generic;
using System.Linq;
-using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
// Validate the length was expected
string path = (string)e.ActualValue;
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ if (OperatingSystem.IsLinux())
{
Assert.Equal(108, path.Length);
}
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ else if (OperatingSystem.IsMacOS())
{
Assert.Equal(104, path.Length);
}
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
-using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
Task.Run(() => { pair.writeablePipe.Write(sent, 0, sent.Length); });
Assert.Equal(sent.Length, pair.readablePipe.Read(received, 0, sent.Length));
Assert.Equal(sent, received);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // WaitForPipeDrain isn't supported on Unix
+ if (OperatingSystem.IsWindows()) // WaitForPipeDrain isn't supported on Unix
pair.writeablePipe.WaitForPipeDrain();
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Xunit;
{
using (ServerClientPair pair = CreateServerClientPair())
{
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
+ if (!OperatingSystem.IsWindows() &&
(pair.readablePipe is NamedPipeClientStream || pair.writeablePipe is NamedPipeClientStream))
{
// On Unix, NamedPipe*Stream is implemented in term of sockets, where information
{
using (ServerClientPair pair = CreateServerClientPair())
{
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
+ if (!OperatingSystem.IsWindows() &&
(pair.readablePipe is NamedPipeClientStream || pair.writeablePipe is NamedPipeClientStream))
{
// On Unix, NamedPipe*Stream is implemented in term of sockets, where information
using System.IO;
using System.Net.Sockets;
-using System.Runtime.InteropServices;
using Xunit;
using Xunit.Abstractions;
Assert.NotNull(hostName);
SocketError error = NameResolutionPal.TryGetAddrInfo(hostName, justAddresses, out hostName, out string[] aliases, out IPAddress[] addresses, out int nativeErrorCode);
- if (error == SocketError.HostNotFound && (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)))
+ if (error == SocketError.HostNotFound && (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()))
{
// On Unix, we are not guaranteed to be able to resove the local host. The ability to do so depends on the
// machine configurations, which varies by distro and is often inconsistent.
using System.Net;
using System.Net.Sockets;
using System.Net.Test.Common;
-using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Xunit;
Assert.NotNull(gp.GetActiveUdpListeners());
Assert.NotNull(gp.GetIPv4GlobalStatistics());
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && !RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")))
+ if (!OperatingSystem.IsMacOS() && !OperatingSystem.IsFreeBSD())
{
// OSX and FreeBSD do not provide IPv6 stats.
Assert.NotNull(gp.GetIPv6GlobalStatistics());
using System.Linq;
using System.Net.Sockets;
using System.Net.Test.Common;
-using System.Runtime.InteropServices;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Text;
public static IEnumerable<object[]> Alpn_TestData()
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
yield return new object[] { new List<SslApplicationProtocol> { SslApplicationProtocol.Http11, SslApplicationProtocol.Http2 }, new List<SslApplicationProtocol> { SslApplicationProtocol.Http2 }, null };
yield return new object[] { new List<SslApplicationProtocol> { SslApplicationProtocol.Http11 }, new List<SslApplicationProtocol> { SslApplicationProtocol.Http11, SslApplicationProtocol.Http2 }, null };
using System.IO;
using System.Net.Test.Common;
-using System.Runtime.InteropServices;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
await Assert.ThrowsAsync<AuthenticationException>(() => tasks[0]);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
// IOException is thrown when trying to read from a disconnected socket.
await Assert.ThrowsAsync<IOException>(() => tasks[1]);
using System.Diagnostics;
using System.IO;
-using System.Runtime.InteropServices;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
public static bool SupportsNullEncryption { get { return s_supportsNullEncryption.Value; } }
- public static bool SupportsHandshakeAlerts { get { return RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.Windows); } }
+ public static bool SupportsHandshakeAlerts { get { return OperatingSystem.IsLinux() || OperatingSystem.IsWindows(); } }
- public static bool SupportsAlpnAlerts { get { return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && PlatformDetection.OpenSslVersion.CompareTo(new Version(1,0,2)) >= 0); } }
+ public static bool SupportsAlpnAlerts { get { return OperatingSystem.IsWindows() || (OperatingSystem.IsLinux() && PlatformDetection.OpenSslVersion.CompareTo(new Version(1,0,2)) >= 0); } }
public static Task WhenAllOrAnyFailedWithTimeout(params Task[] tasks)
=> tasks.WhenAllOrAnyFailed(PassingTestTimeoutMilliseconds);
private static Lazy<bool> s_supportsNullEncryption = new Lazy<bool>(() =>
{
// On Windows, null ciphers (no encryption) are supported.
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
return true;
}
// On macOS, the null cipher (no encryption) is not supported.
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
return false;
}
Assert.True(cbt1 != null, "ChannelBindingKind.Endpoint token data should be returned.");
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
Assert.True(cbt2 == null, "ChannelBindingKind.Unique token data is not expected on OSX platform.");
}
using System.Threading;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography;
-using System.Runtime.InteropServices;
namespace SslStress
{
certReq.CertificateExtensions.Add(new X509EnhancedKeyUsageExtension(new OidCollection { new Oid("1.3.6.1.5.5.7.3.1") }, false));
certReq.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.DigitalSignature, false));
X509Certificate2 cert = certReq.CreateSelfSigned(DateTimeOffset.UtcNow.AddMonths(-1), DateTimeOffset.UtcNow.AddMonths(1));
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
cert = new X509Certificate2(cert.Export(X509ContentType.Pfx));
}
using System.Collections.Generic;
using System.Net.NetworkInformation;
using System.Net.Sockets;
-using System.Runtime.InteropServices;
using Xunit;
namespace System.Net.Tests
// is turned off. Hence dns lookup for it's own hostname fails.
Assert.Equal(SocketError.HostNotFound, exception.SocketErrorCode);
Assert.Throws<SocketException>(() => Dns.GetHostEntryAsync(Dns.GetHostName()).GetAwaiter().GetResult());
- Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX));
+ Assert.True(OperatingSystem.IsLinux() || OperatingSystem.IsMacOS());
}
}
using System.Collections.Generic;
using System.IO;
-using System.Runtime.InteropServices;
using Xunit;
namespace System.Xml.Tests
// Base URI as null is the default for internal Xml operation.
var baseUris = new List<Uri> { null };
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
// The case below does not work on Unix, the '#' ends up treated as a fragment and the path is cut there.
var currDirWithDirSeparator = Environment.CurrentDirectory + Path.DirectorySeparatorChar;
AssertExtensions.Throws<ArgumentOutOfRangeException, ArgumentException>("target", null, () => Environment.GetEnvironmentVariable("test", (EnvironmentVariableTarget)42));
AssertExtensions.Throws<ArgumentOutOfRangeException, ArgumentException>("target", null, () => Environment.SetEnvironmentVariable("test", "test", (EnvironmentVariableTarget)(-1)));
AssertExtensions.Throws<ArgumentOutOfRangeException, ArgumentException>("target", null, () => Environment.GetEnvironmentVariables((EnvironmentVariableTarget)(3)));
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && System.Tests.SetEnvironmentVariable.IsSupportedTarget(EnvironmentVariableTarget.User))
+ if (OperatingSystem.IsWindows() && System.Tests.SetEnvironmentVariable.IsSupportedTarget(EnvironmentVariableTarget.User))
{
AssertExtensions.Throws<ArgumentException>("variable", null, () => Environment.SetEnvironmentVariable(new string('s', 256), "value", EnvironmentVariableTarget.User));
}
Assert.Equal(value, Environment.GetEnvironmentVariable("ThisIsATestEnvironmentVariable"));
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (!OperatingSystem.IsWindows())
{
value = null;
}
return false;
}
- return target == EnvironmentVariableTarget.Process || RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
+ return target == EnvironmentVariableTarget.Process || OperatingSystem.IsWindows();
}
[Fact]
Environment.CurrentDirectory = TestDirectory;
Assert.Equal(Directory.GetCurrentDirectory(), Environment.CurrentDirectory);
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (!OperatingSystem.IsMacOS())
{
// On OSX, the temp directory /tmp/ is a symlink to /private/tmp, so setting the current
// directory to a symlinked path will result in GetCurrentDirectory returning the absolute
public void OSVersion_MatchesPlatform()
{
PlatformID id = Environment.OSVersion.Platform;
- PlatformID expected = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? PlatformID.Win32NT : OperatingSystem.IsBrowser() ? PlatformID.Other : PlatformID.Unix;
+ PlatformID expected = OperatingSystem.IsWindows() ? PlatformID.Win32NT : OperatingSystem.IsBrowser() ? PlatformID.Other : PlatformID.Unix;
Assert.Equal(expected, id);
}
Assert.Contains(version.ToString(2), versionString);
- string expectedOS = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Windows " : OperatingSystem.IsBrowser() ? "Other " : "Unix ";
+ string expectedOS = OperatingSystem.IsWindows() ? "Windows " : OperatingSystem.IsBrowser() ? "Other " : "Unix ";
Assert.Contains(expectedOS, versionString);
}
public void OffsetOf_ValidField_ReturnsExpected()
{
Type t = typeof(FieldAlignmentTest);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || (RuntimeInformation.ProcessArchitecture != Architecture.X86))
+ if (OperatingSystem.IsWindows() || (RuntimeInformation.ProcessArchitecture != Architecture.X86))
{
Assert.Equal(80, Marshal.SizeOf(t));
}
Assert.Equal(new IntPtr(12), Marshal.OffsetOf(t, nameof(FieldAlignmentTest.m_byte2)));
Assert.Equal(new IntPtr(16), Marshal.OffsetOf(t, nameof(FieldAlignmentTest.m_int2)));
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || (RuntimeInformation.ProcessArchitecture != Architecture.X86))
+ if (OperatingSystem.IsWindows() || (RuntimeInformation.ProcessArchitecture != Architecture.X86))
{
Assert.Equal(new IntPtr(24), Marshal.OffsetOf(t, nameof(FieldAlignmentTest.m_double1)));
Assert.Equal(new IntPtr(32), Marshal.OffsetOf(t, nameof(FieldAlignmentTest.m_char1)));
{
Type t = typeof(FieldAlignmentTest_Decimal);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || (RuntimeInformation.ProcessArchitecture != Architecture.X86 && RuntimeInformation.ProcessArchitecture != Architecture.Wasm))
+ if (OperatingSystem.IsWindows() || (RuntimeInformation.ProcessArchitecture != Architecture.X86 && RuntimeInformation.ProcessArchitecture != Architecture.Wasm))
{
Assert.Equal(96, Marshal.SizeOf(t));
}
Assert.Equal(new IntPtr(0), Marshal.OffsetOf(t, nameof(FieldAlignmentTest_Decimal.b)));
Assert.Equal(new IntPtr(8), Marshal.OffsetOf(t, nameof(FieldAlignmentTest_Decimal.p)));
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || (RuntimeInformation.ProcessArchitecture != Architecture.X86 && RuntimeInformation.ProcessArchitecture != Architecture.Wasm))
+ if (OperatingSystem.IsWindows() || (RuntimeInformation.ProcessArchitecture != Architecture.X86 && RuntimeInformation.ProcessArchitecture != Architecture.Wasm))
{
Assert.Equal(new IntPtr(88), Marshal.OffsetOf(t, nameof(FieldAlignmentTest_Decimal.s)));
}
using System.Globalization;
using System.IO;
using System.Linq;
-using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text.RegularExpressions;
using Microsoft.DotNet.RemoteExecutor;
{
public static partial class TimeZoneInfoTests
{
- private static readonly bool s_isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
- private static readonly bool s_isOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
+ private static readonly bool s_isWindows = OperatingSystem.IsWindows();
+ private static readonly bool s_isOSX = OperatingSystem.IsMacOS();
private static string s_strPacific = s_isWindows ? "Pacific Standard Time" : "America/Los_Angeles";
private static string s_strSydney = s_isWindows ? "AUS Eastern Standard Time" : "Australia/Sydney";
using System.Collections.Generic;
using System.Reflection;
-using System.Runtime.InteropServices;
using System.Text;
using Test.Cryptography;
using Xunit;
[Theory, MemberData(nameof(AllValidNames))]
public static void CreateFromName_AllValidNames(string name, string typeName, bool supportsUnixMac)
{
- bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
+ bool isWindows = OperatingSystem.IsWindows();
if (supportsUnixMac || isWindows)
{
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
-using System.Runtime.InteropServices;
using Xunit;
namespace System.Security.Cryptography.Encoding.Tests
}
catch (CryptographicException)
{
- bool isMac = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
+ bool isMac = OperatingSystem.IsMacOS();
Assert.True(isMac, "Exception is only raised on macOS");
}
catch (CryptographicException)
{
- bool isMac = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
+ bool isMac = OperatingSystem.IsMacOS();
Assert.True(isMac, "Exception is only raised on macOS");
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
private static X509KeyStorageFlags GetBestKeyStorageFlags()
{
#if NETCOREAPP
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
// On Windows 7 ephemeral keys with a key usage embedded in the PFX
// are treated differently than Windows 8. So just use the default
return X509KeyStorageFlags.EphemeralKeySet;
}
}
- else if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ else if (!OperatingSystem.IsMacOS())
{
// OSX doesn't allow ephemeral, but every other Unix does.
return X509KeyStorageFlags.EphemeralKeySet;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Runtime.InteropServices;
-
namespace System.Security.Cryptography.X509Certificates.Tests
{
//
// netcoreapp-other: EphemeralKeySet
internal static readonly X509KeyStorageFlags EphemeralIfPossible =
#if !NO_EPHEMERALKEYSET_AVAILABLE
- !RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? X509KeyStorageFlags.EphemeralKeySet :
+ !OperatingSystem.IsMacOS() ? X509KeyStorageFlags.EphemeralKeySet :
#endif
X509KeyStorageFlags.DefaultKeySet;
//
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using Test.Cryptography;
Assert.False(chain.Build(microsoftDotCom));
// Linux and Windows do not search the default system root stores when CustomRootTrust is enabled
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
Assert.Equal(3, chain.ChainElements.Count);
Assert.Equal(X509ChainStatusFlags.UntrustedRoot, chain.AllStatusFlags());
{
X509ChainStatusFlags expectedFlags;
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
expectedFlags = X509ChainStatusFlags.NotSignatureValid;
}
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ else if (OperatingSystem.IsMacOS())
{
// For OSX alone expectedFlags here means OR instead of AND.
// Because the error code changed in 10.13.4 from UntrustedRoot to PartialChain
X509ChainStatusFlags allFlags = chain.AllStatusFlags();
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
// If we're on 10.13.3 or older we get UntrustedRoot.
// If we're on 10.13.4 or newer we get PartialChain.
bool valid = chain.Build(cert);
X509ChainStatusFlags allFlags = chain.AllStatusFlags();
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
// OSX considers this to be valid because it doesn't report NotSignatureValid,
// just PartialChain ("I couldn't find an issuer that made the signature work"),
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Runtime.InteropServices;
using Xunit;
namespace System.Security.Cryptography.X509Certificates.Tests
yield return new object[] { X509KeyStorageFlags.DefaultKeySet };
#if !NO_EPHEMERALKEYSET_AVAILABLE
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (!OperatingSystem.IsMacOS())
yield return new object[] { X509KeyStorageFlags.EphemeralKeySet };
#endif
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Runtime.InteropServices;
using Xunit;
namespace System.Security.Cryptography.X509Certificates.Tests
CryptographicException defaultException = new CryptographicException();
Assert.NotEqual(defaultException.Message, ex.Message);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
Assert.Equal(unchecked((int)0x80092009), ex.HResult);
// TODO (3233): Test that Message is also set correctly
//Assert.Equal("Cannot find the requested object.", ex.Message);
}
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ else if (OperatingSystem.IsMacOS())
{
Assert.Equal(-25257, ex.HResult);
}
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq;
-using System.Runtime.InteropServices;
using Test.Cryptography;
using Xunit;
intermediateCert = TamperIfNeeded(intermediateCert, intermediateErrors);
rootCert = TamperIfNeeded(rootCert, rootErrors);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
// For the lower levels, turn NotSignatureValid into PartialChain,
// and clear all errors at higher levels.
}
}
}
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ else if (OperatingSystem.IsWindows())
{
// Windows only reports NotTimeValid on the start-of-chain (end-entity in this case)
// If it were possible in this suite to get only a higher-level cert as NotTimeValid
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Runtime.InteropServices;
using System.Text;
using Xunit;
Assert.NotSame(expected, match);
// FriendlyName is Windows-only.
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
// Verify that the find result and original are linked, not just equal.
match.FriendlyName = "HAHA";
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
-using System.Runtime.InteropServices;
using System.Security.Cryptography.Pkcs;
using Xunit;
using (var cert = new X509Certificate2(TestData.PfxData, TestData.PfxDataPassword, s_exportableImportFlags))
using (RSA key = cert.GetRSAPrivateKey())
{
- if (dontShroudKey && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (dontShroudKey && OperatingSystem.IsWindows())
{
// CNG keys are only encrypted-exportable, so we need to export them encrypted.
// Then we can import it into a new, fully-exportable key. (Sigh.)
// The .NET Foundation licenses this file to you under the MIT license.
using System.Globalization;
-using System.Runtime.InteropServices;
using System.Security.Cryptography.Pkcs;
using Test.Cryptography;
using Xunit;
//
// Our Unix loader matches the current Windows 10 behavior.
private static readonly bool s_loaderFailsKeysEarly =
- RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
+ OperatingSystem.IsWindows() &&
!PlatformDetection.IsWindows10Version1607OrGreater;
protected abstract void ReadPfx(
byte[] pfxBytes = builder.Encode();
// On macOS the cert will come back with HasPrivateKey being false.
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
using (var publicCert = new X509Certificate2(cert.RawData))
{
// On macOS the cert will come back with HasPrivateKey being false when the
// incorrect key comes first
- if (!correctKeyFirst && RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (!correctKeyFirst && OperatingSystem.IsMacOS())
{
using (var publicCert = new X509Certificate2(cert.RawData))
{
// Obviously this hit some sort of weird corner case in the Win7
// loader, but it's not important to the test.
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
+ if (OperatingSystem.IsWindows() &&
!PlatformDetection.IsWindows8xOrLater)
{
followup = null;
CryptographicException ex = Assert.ThrowsAny<CryptographicException>(
() => coll.Import(pfxBytes, bestPassword, s_importFlags));
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
if (altWin32Error != 0 && ex.HResult != altWin32Error)
{
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Runtime.InteropServices;
using Xunit;
namespace System.Security.Cryptography.X509Certificates.Tests
CryptographicException ex = Assert.ThrowsAny<CryptographicException>(
() => new X509Certificate2(pfxBytes, bestPassword, s_importFlags));
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
if (altWin32Error != 0 && ex.HResult != altWin32Error)
{
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
-using System.Runtime.InteropServices;
using Test.Cryptography;
using Xunit;
{
Assert.NotNull(ecdsa);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
AssertEccAlgorithm(ecdsa, "ECDSA_P256");
}
{
Assert.NotNull(ecdsa);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
AssertEccAlgorithm(ecdsa, "ECDH");
}
{
Assert.NotNull(ecdsa);
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
// If Windows were to start detecting this case as ECDSA that wouldn't be bad,
// but this assert is the only proof that this certificate was made with OpenSSL.
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates.Tests.Common;
using Xunit;
// [ActiveIssue("https://github.com/dotnet/runtime/issues/31246")]
// Linux reports this code at more levels than Windows does.
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ if (OperatingSystem.IsLinux())
{
issuerExtraProblems |= X509ChainStatusFlags.NotValidForUsage;
}
// [ActiveIssue("https://github.com/dotnet/runtime/issues/31246")]
// Linux reports this code at more levels than Windows does.
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ if (OperatingSystem.IsLinux())
{
issuerExtraProblems |= X509ChainStatusFlags.NotValidForUsage;
}
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
-using System.Runtime.InteropServices;
using Test.Cryptography;
using Xunit;
string expectedHex;
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
expectedHex = testCase.GetBmpEncoding() ?? testCase.GetPreferredEncoding();
}