Skip to content

Commit

Permalink
Mark OperatingSystem.IsXXX properties as non-versionable (dotnet#68250)
Browse files Browse the repository at this point in the history
It allows them to be inlined by the R2R compiler.
  • Loading branch information
jkotas authored Apr 20, 2022
1 parent 677f6e5 commit 68e4794
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public static bool IsOSPlatformVersionAtLeast(string platform, int major, int mi
/// <summary>
/// Indicates whether the current application is running as WASM in a Browser.
/// </summary>
[NonVersionable]
public static bool IsBrowser() =>
#if TARGET_BROWSER
true;
Expand All @@ -130,6 +131,7 @@ public static bool IsBrowser() =>
/// <summary>
/// Indicates whether the current application is running on Linux.
/// </summary>
[NonVersionable]
public static bool IsLinux() =>
#if TARGET_LINUX && !TARGET_ANDROID
true;
Expand All @@ -140,6 +142,7 @@ public static bool IsLinux() =>
/// <summary>
/// Indicates whether the current application is running on FreeBSD.
/// </summary>
[NonVersionable]
public static bool IsFreeBSD() =>
#if TARGET_FREEBSD
true;
Expand All @@ -156,6 +159,7 @@ public static bool IsFreeBSDVersionAtLeast(int major, int minor = 0, int build =
/// <summary>
/// Indicates whether the current application is running on Android.
/// </summary>
[NonVersionable]
public static bool IsAndroid() =>
#if TARGET_ANDROID
true;
Expand All @@ -173,6 +177,7 @@ public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build =
/// Indicates whether the current application is running on iOS or MacCatalyst.
/// </summary>
[SupportedOSPlatformGuard("maccatalyst")]
[NonVersionable]
public static bool IsIOS() =>
#if TARGET_IOS || TARGET_MACCATALYST
true;
Expand All @@ -184,12 +189,14 @@ public static bool IsIOS() =>
/// Check for the iOS/MacCatalyst version (returned by 'libobjc.get_operatingSystemVersion') with a >= version comparison. Used to guard APIs that were added in the given iOS release.
/// </summary>
[SupportedOSPlatformGuard("maccatalyst")]
[NonVersionable]
public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0)
=> IsIOS() && IsOSVersionAtLeast(major, minor, build, 0);

/// <summary>
/// Indicates whether the current application is running on macOS.
/// </summary>
[NonVersionable]
public static bool IsMacOS() =>
#if TARGET_OSX
true;
Expand All @@ -213,6 +220,7 @@ public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0
/// <summary>
/// Indicates whether the current application is running on Mac Catalyst.
/// </summary>
[NonVersionable]
public static bool IsMacCatalyst() =>
#if TARGET_MACCATALYST
true;
Expand All @@ -229,6 +237,7 @@ public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int bui
/// <summary>
/// Indicates whether the current application is running on tvOS.
/// </summary>
[NonVersionable]
public static bool IsTvOS() =>
#if TARGET_TVOS
true;
Expand All @@ -245,6 +254,7 @@ public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0)
/// <summary>
/// Indicates whether the current application is running on watchOS.
/// </summary>
[NonVersionable]
public static bool IsWatchOS() =>
#if TARGET_WATCHOS
true;
Expand All @@ -261,6 +271,7 @@ public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build =
/// <summary>
/// Indicates whether the current application is running on Windows.
/// </summary>
[NonVersionable]
public static bool IsWindows() =>
#if TARGET_WINDOWS
true;
Expand Down

0 comments on commit 68e4794

Please sign in to comment.