Skip to content

CA1416 about API not being available on Mac Catalyst when it is #7239

Open
@rolfbjarne

Description

Analyzer

Diagnostic ID: CA1416: This call site is reachable on: 'iOS' 13.0 and later, 'maccatalyst' 15.0 and later. 'AppDelegate.DoSomething()' is only supported on: 'ios' 14.0 and later.

Describe the bug

An API decorated with [SupportedOSPlatform("maccatalyst")] (no version) doesn't seem to be detected as supported on Mac Catalyst.

Steps To Reproduce

  1. Create a new iOS project (dotnet new ios).
  2. Set SupportedOSPlatformVersion=13.0 in the csproj.
  3. Add the following code to it (for instance in the AppDelegate class / in AppDelegate.cs):
private void Tapped()
{
	if (OperatingSystem.IsIOSVersionAtLeast(15,0))
		DoSomething ();
}

[SupportedOSPlatform ("ios14.0")]
[SupportedOSPlatform ("maccatalyst")]
public void DoSomething () {}

Complete test project (+ binlog):
ios-plain-52d66f2.zip

Expected behavior

No warning.

Actual behavior

warning CA1416: This call site is reachable on: 'iOS' 13.0 and later, 'maccatalyst' 15.0 and later. 'AppDelegate.DoSomething()' is only supported on: 'ios' 14.0 and later.

Note that the warning message is wrong on more than one account:

  1. The call site is reachable on iOS 15.0 (not 13.0).
  2. The called API is (correctly) supported on iOS 14+, but also on all versions of Mac Catalyst.

Additional context

Adding a version to the maccatalyst attribute text fixes the warning.

So there's no warning with this:

private void Tapped()
{
	if (OperatingSystem.IsIOSVersionAtLeast(15,0))
		DoSomething ();
}

[SupportedOSPlatform ("ios14.0")]
[SupportedOSPlatform ("maccatalyst14.0")]
public void DoSomething () {}

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions