Open
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
- Create a new iOS project (
dotnet new ios
). - Set
SupportedOSPlatformVersion=13.0
in the csproj. - 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:
- The call site is reachable on iOS 15.0 (not 13.0).
- 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 () {}
Metadata
Metadata
Assignees
Labels
No labels
Activity