Skip to content
Merged
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
6 changes: 6 additions & 0 deletions PolyShim/Net50/OperatingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Runtime.InteropServices;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Versioning;

#if !POLYSHIM_INCLUDE_COVERAGE
[ExcludeFromCodeCoverage]
Expand All @@ -16,20 +17,25 @@ internal static class MemberPolyfills_Net50_OperatingSystem
// Can only detect the platform on .NET Standard 1.3+
#if !NETSTANDARD || NETSTANDARD1_3_OR_GREATER
// https://learn.microsoft.com/dotnet/api/system.operatingsystem.isfreebsd
[SupportedOSPlatformGuard("freebsd")]
public static bool IsFreeBSD() => RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD);

// https://learn.microsoft.com/dotnet/api/system.operatingsystem.islinux
[SupportedOSPlatformGuard("linux")]
public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);

// https://learn.microsoft.com/dotnet/api/system.operatingsystem.ismacos
[SupportedOSPlatformGuard("macos")]
public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX);

// https://learn.microsoft.com/dotnet/api/system.operatingsystem.iswindows
[SupportedOSPlatformGuard("windows")]
public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

// Can only detect OS version on .NET Standard 2.0+ and .NET Core 2.0
#if (!NETSTANDARD || NETSTANDARD2_0_OR_GREATER) && (!NETCOREAPP || NETCOREAPP2_0_OR_GREATER)
// https://learn.microsoft.com/dotnet/api/system.operatingsystem.iswindowsversionatleast
[SupportedOSPlatformGuard("windows")]
public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0)
{
if (!IsWindows())
Expand Down
Loading