Skip to content

[API Proposal]: Make IsApplePlatform public #113262

Closed

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

Activity

  1. added
    api-suggestion
    on Mar 7, 2025
  2. ghost added
    needs-area-label
    on Mar 7, 2025
  3. added
    untriaged
    on Mar 7, 2025
  4. added and removed
    needs-area-label
    on Mar 7, 2025
  5. dotnet-policy-service commented on Mar 7, 2025

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-runtime
    See info in area-owners.md if you want to be subscribed.

  6. added
    in-pr
    on Mar 7, 2025
  7. kleisauke commented on Mar 25, 2025

    @kleisauke

    This could be useful to select the correct library extension (i.e. *.dylib) in a DllImportResolver callback. See for example commit kleisauke/net-vips@0fa851c.

  8. jeffhandley commented on Jul 26, 2025

    @jeffhandley
    Member

    @lewing / @steveisok -- What are your thoughts on this? Any risk you can see in exposing this as a public property?

  9. added
    needs-further-triage
    and removed
    untriaged
    in-pr
    on Jul 26, 2025
  10. added this to the Future milestone on Jul 26, 2025
  11. steveisok commented on Jul 26, 2025

    @steveisok
    Member

    @lewing / @steveisok -- What are your thoughts on this? Any risk you can see in exposing this as a public property?

    I don't see much risk. It's a conveinence when dealing with all the apple configurations.

  12. added
    api-ready-for-review
    and removed
    api-suggestion
    needs-further-triage
    on Jul 11, 2026
  13. bartonjs commented on Sep 8, 2026

    @bartonjs
    Member

    Video

    Looks good as proposed

    namespace System;
    
    public partial class OperatingSystem
    {
        public static bool IsApplePlatform();
    }
  14. added
    api-approved
    and removed
    api-ready-for-review
    on Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-approvedarea-System.Runtime

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions