Call site reachable warning for enums when passing it to a safe function
Closed this issue · 3 comments
Description
There are some instances where you need to pass an enum to a function that actually handles the version correctly:
Internally this function will not use the flag if version is less than 24, therefore we should not get this warning.
Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
8.0.70 SR7
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
All
Did you find any workaround?
Ignore warning
Relevant log output
No response
I can repro this issue at Android platform on the latest 17.11.0 Preview 5.0 (8.0.61&8.0.70).
According to the documentation for androidx.core.app.ServiceCompat.stopForeground
, the constant it accepts is androidx.core.app.ServiceCompat.STOP_FOREGROUND_REMOVE
.
You are using an enum value that is based on android.app.Service.STOP_FOREGROUND_REMOVE
.
You just happened to get lucky that they have the same value, but you should be using the C# AndroidX.Core.App.ServiceCompat.StopForegroundRemove
constant instead.
Thank you so much @jpobst ! However, is it the same for the service types?
ServiceCompat.StartForeground(this, NotificationUtils.SERVICE_BIRTH_MONITOR_ALARM_NOTIFICATION_ID, GenerateNotification(), (int)ForegroundService.TypeMediaPlayback);
Here I get a warning on ForegroundService.TypeMediaPlayback