Wrong CA1416 warning within members annotated with `[SupportedOSPlatformGuard]`
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
I just noticed that if you use `[SupportedOSPlatformGuard]`, the normal CA1416 analyzer breaks down. Consider this snippet:
```xml
Exe
net10.0-windows10.0.26100.0
10.0.18362.0
```
```csharp
using System.Runtime.Versioning;
using Windows.Foundation.Metadata;
using Windows.UI.Composition;
class C
{
public void M1()
{
// No warning (correct)
_ = ApiInformation.IsMethodPresent(
typeName: typeof(CompositionEasingFunction).FullName,
methodName: nameof(CompositionEasingFunction.CreatePowerEasingFunction));
}
[SupportedOSPlatformGuard("windows10.0.20348.0")]
public bool M2() => ApiInformation.IsMethodPresent(
typeName: typeof(CompositionEasingFunction).FullName,
methodName: nameof(CompositionEasingFunction.CreatePowerEasingFunction)); // warning..?!?
}
```
This gives you this:
If you add `[SupportedOSPlatformGuard]`, the CA1416 analyzer starts firing **even if the project has a higher minimum OS version**.
We're having dozens of hits in the Microsoft Store (we just updated the Windows SDK to get the new annotations).
cc. @sbomer could you help take a quick look if you can? Thank you! 🙂
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.