Skip to content

Commit 97d2167

Browse files
committed
Use OperatingSystem where possible
1 parent d702b68 commit 97d2167

4 files changed

Lines changed: 10 additions & 16 deletions

File tree

PolyShim.Tests/Net50/ProcessTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using System.Diagnostics;
2-
using System.Runtime.InteropServices;
1+
using System;
2+
using System.Diagnostics;
33
using System.Threading.Tasks;
44
using FluentAssertions;
55
using Xunit;
@@ -16,10 +16,8 @@ public async Task WaitForExitAsync_Test()
1616
{
1717
StartInfo = new ProcessStartInfo
1818
{
19-
FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "cmd" : "sh",
20-
Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
21-
? "/c timeout 1"
22-
: "-c 'sleep 1'",
19+
FileName = OperatingSystem.IsWindows() ? "cmd" : "sh",
20+
Arguments = OperatingSystem.IsWindows() ? "/c timeout 1" : "-c 'sleep 1'",
2321
CreateNoWindow = true,
2422
UseShellExecute = false,
2523
},

PolyShim.Tests/NetCore30/ProcessTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using System.Diagnostics;
2-
using System.Runtime.InteropServices;
1+
using System;
2+
using System.Diagnostics;
33
using FluentAssertions;
44
using Xunit;
55

@@ -15,10 +15,8 @@ public void Kill_Test()
1515
{
1616
StartInfo = new ProcessStartInfo
1717
{
18-
FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "cmd" : "sh",
19-
Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
20-
? "/c timeout 1"
21-
: "-c 'sleep 1'",
18+
FileName = OperatingSystem.IsWindows() ? "cmd" : "sh",
19+
Arguments = OperatingSystem.IsWindows() ? "/c timeout 1" : "-c 'sleep 1'",
2220
CreateNoWindow = true,
2321
UseShellExecute = false,
2422
},

PolyShim/NetCore20/Path.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System;
99
using System.IO;
1010
using System.Linq;
11-
using System.Runtime.InteropServices;
1211

1312
internal static partial class PolyfillExtensions
1413
{
@@ -19,7 +18,7 @@ internal static partial class PolyfillExtensions
1918
// https://learn.microsoft.com/dotnet/api/system.io.path.getrelativepath
2019
public static string GetRelativePath(string relativeTo, string path)
2120
{
22-
var pathStringComparison = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
21+
var pathStringComparison = OperatingSystem.IsWindows()
2322
? StringComparison.OrdinalIgnoreCase
2423
: StringComparison.Ordinal;
2524

PolyShim/NetCore30/Process.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System.Diagnostics;
1010
using System.Linq;
1111
using System.Management;
12-
using System.Runtime.InteropServices;
1312

1413
internal static partial class PolyfillExtensions
1514
{
@@ -54,7 +53,7 @@ static void KillProcessTree(int processId)
5453
}
5554

5655
// Currently, this polyfill only supports Windows
57-
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
56+
if (!OperatingSystem.IsWindows())
5857
{
5958
process.Kill();
6059
return;

0 commit comments

Comments
 (0)