Open
Description
Background and motivation
When people want check if current application is running on Apple platforms, like macOS, iOS, watchOS, tvOS, they probably need to call OperatingSystem.IsMacOS()
and OperatingSystem.IsIOS()
, etc.
Perhaps we should provide a public method IsApplePlatform()
.
We already have such internal method:
runtime/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs
Lines 245 to 250 in 8a9d492
API Proposal
[NonVersionable]
public static bool IsApplePlatform() =>
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || TARGET_WATCHOS
true;
#else
false;
#endif
API Usage
if (OperatingSystem.IsApplePlatform())
{
Console.WriteLine("Hello World from Cupertino, California");
}
Alternative Designs
No response
Risks
No response