-
Notifications
You must be signed in to change notification settings - Fork 486
Description
Analyzer
Diagnostic ID: CA1416: This call site is reachable on: 'macOS/OSX' 15.0 and later, 'tvos' 12.2 and later. 'Other.DoSomething()' is only supported on: 'tvos' 15.0 and later.
Analyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: SDK 9.0.100
Describe the bug
Incorrect CA1416 is reported when there are more than one SupportedOSPlatformGuard
on a member.
Steps To Reproduce
Test project:
Binlog:
This is the code:
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Versioning;
class C {
[SupportedOSPlatform ("tvos15.0")]
[SupportedOSPlatform ("macos15.0")]
public static void DoSomething ()
{
}
[SupportedOSPlatform ("macos15.0")]
[SupportedOSPlatform ("tvos12.2")]
static void GetFilter (string filterName)
{
if (IsAtLeast) {
DoSomething ();
}
}
[SupportedOSPlatformGuard ("macos15.0")]
[SupportedOSPlatformGuard ("tvos15.0")]
static bool IsAtLeast = true;
}
This reports:
warning CA1416: This call site is reachable on: 'macOS/OSX' 15.0 and later, 'tvos' 12.2 and later. 'C.DoSomething()' is only supported on: 'tvos' 15.0 and later. (
Which is incorrect, because the call site is not reachable on tvos12.2 or later (due to the SupportedOSPlatformGuard attribute on IsAtLeast
).
Removing either of the macos
or tvos
availability attributes on all members fixes the warning.
Expected behavior
No warning.
Actual behavior
warning CA1416: This call site is reachable on: 'macOS/OSX' 15.0 and later, 'tvos' 12.2 and later. 'C.DoSomething()' is only supported on: 'tvos' 15.0 and later. (