-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Bug: Platform Analyzer (CA1416) ignores OperatingSystem.IsIOSVersionAtLeast guard clause #30681
Copy link
Copy link
Open
Labels
partner/maciosIssues for the Mac / iOS SDKIssues for the Mac / iOS SDKplatform/ioss/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
Milestone
Description
Description
Hello .NET MAUI Team,
I'd like to report an issue where the platform compatibility
analyzer (CA1416) incorrectly flags a platform-specific API
call even when it is properly protected by an
OperatingSystem.IsIOSVersionAtLeast() check.
This results in a false-positive warning (which is promoted to
an error in the sample project), preventing the project from
building when targeting an older iOS version, despite the code
being perfectly safe.
if (OperatingSystem.IsIOSVersionAtLeast(13, 0))
{
var request = new BackgroundTasks.BGAppRefreshTaskRequest("com.companyname.mauibugrepro.refreshtask");
}
Steps to Reproduce
- Clone the reproduction repository.
- Navigate to the project's root directory.
- Run the following command in your terminal:
dotnet build -f net9.0-ios
-p:RuntimeIdentifier=iossimulator-x64
Link to public reproduction project repository
https://github.com/yuki2006/maui_sample
Version with bug
9.0.50 SR5
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
No response
Did you find any workaround?
Wrap the code with #pragma
Relevant log output
dotnet build -f net9.0-ios
-p:RuntimeIdentifier=iossimulator-x64
MauiBugRepro net9.0-ios 1 件のエラーと 1 件の警告で失敗しました (1.7 秒)
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.5/18.5.9207/tools/msbuild/Xamarin.Shared.targets(609,3): warning :
サポートされている iPhone の向きが設定されていません
/Users/admin/maui_bug/MauiBugRepro/Platforms/iOS/AppDelegate.cs(18,27): error CA1416: この呼び出しサイトは 'iOS' 12.2 以降, 'maccatalyst' 13.0 以降 で到達可能です。'BGAppRefreshTaskRequest' は 'ios' 13.0 以降 でのみサポートされています。 (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
partner/maciosIssues for the Mac / iOS SDKIssues for the Mac / iOS SDKplatform/ioss/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
Todo