-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mono.Android] Fix Context.RegisterReceiver() enumification (#7735)
Fixes: #7503 Context: e33eb53 Context: df6c716 Context: 76ab8b2 The bindings for [`Context.registerReceiver(BroadcastReceiver, IntentFilter, int)`][0] and related overloads incorrectly enumified the `int` parameter as the `Android.Content.ActivityFlags` enum (e33eb53), when it should have been `Android.Content.ReceiverFlags` (df6c716). Unfortunately we can't directly fix this, as the bound `Context.RegisterReceiver(BroadcastReceiver, IntentFilter, ActivityFlags)` method is *`abstract`*, and thus changing it would break compatibility. Fix this without breaking API by: 1. Creating new overload methods which chain to the existing methods 2. Mark the existing methods and method overrides as `[Obsolete]`. a'la: partial class Context { [Obsolete ("This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead.")] public abstract Intent? RegisterReceiver (BroadcastReceiver? receiver, IntentFilter? filter, [GeneratedEnum] ActivityFlags flags); public Intent? RegisterReceiver (BroadcastReceiver? receiver, IntentFilter? filter, ReceiverFlags flags) => RegisterReceiver (receiver, filter, (ActivityFlags)flags); } A concern with this approach is that it means that a public `abstract` method is now `[Obsolete]`, which would make it "weird" to override. However, this is a method that should *never* be overridden by user code, so we think this is an acceptable compromise. Additionally, it was noticed that the public API tracking added in 76ab8b2 did not flag this change as an error, only a warning. Convert the RS0016 and RS0017 warnings into errors to ensure that any new public API is accounted for. [0]: https://developer.android.com/reference/android/content/Context#registerReceiver(android.content.BroadcastReceiver,%20android.content.IntentFilter,%20int)
- Loading branch information
Showing
4 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters