From 6356354b35d6efe5888bb52b3273d10b8e9ebbfe Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 20 Apr 2022 08:40:46 -0700 Subject: [PATCH] Mark OperatingSystem.IsXXX properties as non-versionable (#68250) It allows them to be inlined by the R2R compiler. --- .../src/System/OperatingSystem.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs index c1d63f8a3bfa3..5f1d83dd01ee3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs @@ -120,6 +120,7 @@ public static bool IsOSPlatformVersionAtLeast(string platform, int major, int mi /// /// Indicates whether the current application is running as WASM in a Browser. /// + [NonVersionable] public static bool IsBrowser() => #if TARGET_BROWSER true; @@ -130,6 +131,7 @@ public static bool IsBrowser() => /// /// Indicates whether the current application is running on Linux. /// + [NonVersionable] public static bool IsLinux() => #if TARGET_LINUX && !TARGET_ANDROID true; @@ -140,6 +142,7 @@ public static bool IsLinux() => /// /// Indicates whether the current application is running on FreeBSD. /// + [NonVersionable] public static bool IsFreeBSD() => #if TARGET_FREEBSD true; @@ -156,6 +159,7 @@ public static bool IsFreeBSDVersionAtLeast(int major, int minor = 0, int build = /// /// Indicates whether the current application is running on Android. /// + [NonVersionable] public static bool IsAndroid() => #if TARGET_ANDROID true; @@ -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. /// [SupportedOSPlatformGuard("maccatalyst")] + [NonVersionable] public static bool IsIOS() => #if TARGET_IOS || TARGET_MACCATALYST true; @@ -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. /// [SupportedOSPlatformGuard("maccatalyst")] + [NonVersionable] public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsIOS() && IsOSVersionAtLeast(major, minor, build, 0); /// /// Indicates whether the current application is running on macOS. /// + [NonVersionable] public static bool IsMacOS() => #if TARGET_OSX true; @@ -213,6 +220,7 @@ public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0 /// /// Indicates whether the current application is running on Mac Catalyst. /// + [NonVersionable] public static bool IsMacCatalyst() => #if TARGET_MACCATALYST true; @@ -229,6 +237,7 @@ public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int bui /// /// Indicates whether the current application is running on tvOS. /// + [NonVersionable] public static bool IsTvOS() => #if TARGET_TVOS true; @@ -245,6 +254,7 @@ public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) /// /// Indicates whether the current application is running on watchOS. /// + [NonVersionable] public static bool IsWatchOS() => #if TARGET_WATCHOS true; @@ -261,6 +271,7 @@ public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = /// /// Indicates whether the current application is running on Windows. /// + [NonVersionable] public static bool IsWindows() => #if TARGET_WINDOWS true;