Skip to content

Xamarin developers get warnings when they call APIs that aren't available on the OS version they target #45193

Closed

Description

@terrajobst

We already have the analyzer, but this work captures ensuring the Xamarin bindings for Apple & Android platform are using the platform compatibility annotations (as opposed to ones specific to the bindings).

https://github.com/dotnet/designs/blob/main/accepted/2020/platform-checks/platform-checks.md#attributes

Work Items

Activity

  1. added
    untriaged
    on Nov 25, 2020
  2. added
    User Story
    and removed
    untriaged
    on Nov 25, 2020
  3. changed the title [-]As a Xamarin developer, I get warnings when I call APIs that aren't available on the OS version I want to run on[/-] [+]Xamarin developers get warnings when they call APIs that aren't available on the OS version they target[/+] on Nov 27, 2020
  4. added
    Priority:0
    on Dec 17, 2020
  5. added this to the 6.0.0 milestone on Feb 9, 2021
  6. dotMorten commented on Jun 29, 2021

    @dotMorten

    Is this the reason I'm seeing all these (invalid) warnings when targeting net6.0-ios13 ?

    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocationManager.StopUpdatingHeading()' is only supported on: 'macOS/OSX' 11.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocationManager.RequestWhenInUseAuthorization()' is only supported on: 'macOS/OSX' 11.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocationManager.StartUpdatingHeading()' is only supported on: 'macOS/OSX' 11.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'UIApplication.StatusBarOrientation.get' is unsupported on: 'ios' 9.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'UIApplication.StatusBarOrientation' is unsupported on: 'ios' 9.0 and later, 'macOS/OSX' 10.14 and later, 'maccatalyst' 13.1 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocationManager.AuthorizationStatus.get' is only supported on: 'macOS/OSX' 11.0 and later, 'tvos' 14.0 and later, 'ios' 14.0 and later, 'maccatalyst' 14.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocationManager.AuthorizationStatus' is only supported on: 'macOS/OSX' 11.0 and later, 'tvos' 14.0 and later, 'ios' 14.0 and later, 'maccatalyst' 14.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocationManager.Status.get' is unsupported on: 'ios' 14.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocationManager.Status' is unsupported on: 'ios' 14.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLFloor.Level' is only supported on: 'macOS/OSX' 10.15 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocation.Floor.get' is only supported on: 'macOS/OSX' 10.15 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocation.Floor' is only supported on: 'macOS/OSX' 10.15 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocation.Course' is only supported on: 'tvos' 13.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocation.Course.get' is only supported on: 'tvos' 13.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLFloor.Level' is only supported on: 'macOS/OSX' 10.15 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocation.Floor.get' is only supported on: 'macOS/OSX' 10.15 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocation.Floor' is only supported on: 'macOS/OSX' 10.15 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocation.Speed.get' is only supported on: 'tvos' 13.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocation.Speed' is only supported on: 'tvos' 13.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocation.Course' is only supported on: 'tvos' 13.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocation.Course.get' is only supported on: 'tvos' 13.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocation.Speed' is only supported on: 'tvos' 13.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocation.Speed.get' is only supported on: 'tvos' 13.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocationManager.HeadingAvailable.get' is only supported on: 'macOS/OSX' 11.0 and later.
    warning CA1416: This call site is reachable on: 'iOS' 13.0 and later. 'CLLocationManager.HeadingAvailable' is only supported on: 'macOS/OSX' 11.0 and later.
    
  7. jeffhandley commented on Aug 11, 2021

    @jeffhandley
    Member

    Is this the reason I'm seeing all these (invalid) warnings when targeting net6.0-ios13 ?

    This does look related. @dotMorten, if this is still happening with Preview 7, could you please file a fresh issue for those invalid diagnostics? Please tag @steveisok, @buyaa-n, and me in the issue. Thanks for the help!

  8. dotMorten commented on Aug 11, 2021

    @dotMorten

    @jeffhandley Thanks! I literally just got to upgrade and noticed warnings were still there, so wanted to go find this issue so I could comment that it hasn't be solved. Thanks for the notification so I didn't have to go search for it :)

    image

  9. dotMorten commented on Aug 11, 2021

    @dotMorten

    @jeffhandley btw why a fresh issue? Isn't this issue here still valid?

  10. jeffhandley commented on Aug 11, 2021

    @jeffhandley
    Member

    We have this issue set up as a 'User Story', which is more of a tracking type issue as opposed to a bug report. By filing a fresh issue, it'll show up as a bug and go through our triage process properly and show up on our radar more effectively.

    Thanks for checking against Preview 7!

  11. buyaa-n commented on Aug 12, 2021

    @buyaa-n
    Contributor

    Is this the reason I'm seeing all these (invalid) warnings when targeting net6.0-ios13 ?

    @dotMorten why and which one do you think is invalid? Looks all valid to me

  12. dotMorten commented on Aug 12, 2021

    @dotMorten

    @buyaa-n CLLocation APIs are supported on iOS since more or less forever.

  13. buyaa-n commented on Aug 12, 2021

    @buyaa-n
    Contributor

    CLLocation APIs are supported on iOS since more or less forever.

    Then that API need to be annotated with SupportedOSPlatform("ios[optional_version]"), i guess there is a warning because it is only annotated with SupportedOSPlatform("macOS[optional_version]") or so. But I cannot find such API in runtime, so i could not see the exact cause, also as the API is not in runtime please file an issue in the repo wherever the API defined

  14. ghost locked as resolved and limited conversation to collaborators on Sep 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Priority:0User Storyarea-Metaos-androidos-ios

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions