-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Runtime
Milestone
Description
Background and Motivation
As per the header, all changes to src/libraries/System.Runtime/ref/System.Runtime.cs are subject to API review. This is a minimal change to class OperatingSystem to add checks for Mac Catalyst, directly copying the existing behaviour of IsTvOS() and IsTvOSVersionAtLeast
Roughly speaking, Mac Catalyst exposes the iOS API subset for use on macOS, allowing for source (but not binary) compatibility with iOS/iPad apps. A number of the default apps in recent macOS are actually Catalyst apps.
Ref: #47517
Proposed API
diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs
index 67894c17773..8ed0532b930 100644
--- a/src/libraries/System.Runtime/ref/System.Runtime.cs
+++ b/src/libraries/System.Runtime/ref/System.Runtime.cs
@@ -3099,6 +3099,8 @@ public sealed partial class OperatingSystem : System.ICloneable, System.Runtime.
public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0) { throw null; }
public static bool IsMacOS() { throw null; }
public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) { throw null; }
+ public static bool IsMacCatalyst() { throw null; }
+ public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) { throw null; }
public static bool IsTvOS() { throw null; }
public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) { throw null; }
public static bool IsWatchOS() { throw null; }Usage Examples
Right now, my main usage is in correctly gating which tests are run specifically against the correct platform, i.e.
+ [Fact, PlatformSpecific(TestPlatforms.MacCatalyst)]
+ public static void TestIsOSPlatform_MacCatalyst() => TestIsOSPlatform("MacCatalyst", OperatingSystem.IsMacCatalyst);Alternative Designs
You could argue that adding one bool-return function per OS isn't very scalable, but that ship already sailed a long time ago I think.
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Runtime