Skip to content

[API Proposal]: Make IsApplePlatform public #113262

Open
@makazeu

Description

@makazeu

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:

internal static bool IsApplePlatform() =>
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
true;
#else
false;
#endif

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Runtimein-prThere is an active PR which will close this issue when it is mergeduntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions