Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] CA1416 false positive #7578

Open
tipa opened this issue Feb 17, 2025 · 0 comments
Open

[iOS] CA1416 false positive #7578

tipa opened this issue Feb 17, 2025 · 0 comments

Comments

@tipa
Copy link

tipa commented Feb 17, 2025

Analyzer

Diagnostic ID: CA1416: This call site is reachable on: 'iOS' 13.0 and later, 'maccatalyst' 13.0 and later, 'macOS/OSX' 15.0 and later. 'NSTextHighlightStyle.Default' is only supported on: 'ios' 18.0 and later, 'maccatalyst' 18.0 and later, 'tvos' 18.0 and later

Analyzer source

SDK: Built-in CA analyzers in .NET 5 SDK or later

Version: SDK 9.0.200

Describe the bug

CA1416 is incorrectly reported

Steps To Reproduce

Solution with iOS, macOS and shared project.
This shared code is in the shared project:

#if IOS
using StringAttributeKey = UIKit.UIStringAttributeKey;
#else
using StringAttributeKey = AppKit.NSStringAttributeKey;
#endif

...

var attrs = new NSMutableDictionary();
if (OperatingSystem.IsIOSVersionAtLeast(18) || OperatingSystem.IsMacOSVersionAtLeast(15))
{
    attrs[StringAttributeKey.TextHighlightStyle] = NSObject.FromObject(NSTextHighlightStyle.Default.GetConstant());
    attrs[StringAttributeKey.TextHighlightColorScheme] = NSObject.FromObject(NSTextHighlightColorScheme.Orange.GetConstant());
}

Example project: test.zip

Expected behavior

No warning

Actual behavior

warning CA1416 is incorrectly reported

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant