-
Notifications
You must be signed in to change notification settings - Fork 470
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
.NET7.0: Suppress CA1416 when wrapped in UIDevice.CheckSystemVersion #6955
Comments
From @rolfbjarne on Tue, 29 Aug 2023 17:22:29 GMT The [Export("systemImageNamed:")]
[SupportedOSPlatform("tvos13.0")]
[SupportedOSPlatform("ios13.0")]
[SupportedOSPlatform("maccatalyst")]
[BindingImpl((BindingImplOptions)3)]
public static UIImage? GetSystemImage(string name) and UIDevice.CheckSystemVersion is supposed to handle this correctly, due to the It seems to be related to Mac Catalyst, because if I add a public void CA1416()
{
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
{
UIImage? foo = UIImage.GetSystemImage("foo");
DoSomethingWithFoo(); // This reports: warning CA1416: This call site is reachable on: 'iOS' 12.0 and later, 'maccatalyst' 13.0 and later. 'AppDelegate.DoSomethingWithFoo()' is only supported on: 'ios' 13.0 and later.
}
}
[SupportedOSPlatform("ios13.0")]
[SupportedOSPlatform("maccatalyst")]
private void DoSomethingWithFoo()
{
UIImage? foo = UIImage.GetSystemImage("foo");
} @buyaa-n any idea what might be going wrong here? |
Tagging subscribers to this area: @dotnet/area-meta Issue DetailsFrom @projectgoav on Tue, 29 Aug 2023 08:25:43 GMT Steps to Reproduce
public void CA1416()
{
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
{
UIImage? foo = UIImage.GetSystemImage("foo");
}
} Expected BehaviorThere should be no build warnings Actual Behavior
I'd be nice if this warning was suppressed when the calls are wrapped in It appears that adding the public void CA1416()
{
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
{
UIImage? foo = UIImage.GetSystemImage("foo"); // CA1416
DoSomethingWithFoo(); // No CA1416
}
}
[SupportedOSPlatform("ios13.0")]
private void DoSomethingWithFoo()
{
UIImage? foo = UIImage.GetSystemImage("foo");
}
EnvironmentVersion information
Build LogsExample Project (If Possible)Copied from original issue dotnet/macios#18856
|
What
As you know |
Correct. |
This looks has same root cause as #7239 |
From @projectgoav on Tue, 29 Aug 2023 08:25:43 GMT
Steps to Reproduce
Expected Behavior
There should be no build warnings
Actual Behavior
Warning CA1416: This call site is reachable on: 'iOS' 12.0 and later, 'maccatalyst' 13.0 and later. 'UIImage.GetSystemImage(string)' is only supported on: 'ios' 13.0 and later. (CA1416)
I'd be nice if this warning was suppressed when the calls are wrapped in
UIDevice.CheckSystemVersion
. It'd be great if there was some check up the callstack to see if this method was suitably protected, but at the very least it'd be great if it were to check in the same scope before generating the warning.It appears that adding the
SupportedOSPlatform
attribute to a method already supports this.Environment
Version information
Build Logs
Example Project (If Possible)
CA1416.zip
Copied from original issue dotnet/macios#18856
The text was updated successfully, but these errors were encountered: