-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[generator] enum map.csv can set
@deprecated-since
for enum values (#…
…1070) Context: dotnet/android#7670 While auditing the `Mono.Android.dll`, we've found that some constants were added to the wrong enums. Consider [`xamarin-android/src/Mono.Android/map.csv`][0], lines 739-743: E,28,android/app/usage/UsageStatsManager.STANDBY_BUCKET_ACTIVE,10,Android.App.Usage.StandbyBucket,Active,remove, E,28,android/app/usage/UsageStatsManager.STANDBY_BUCKET_FREQUENT,30,Android.App.Usage.StandbyBucket,Frequent,remove, E,28,android/app/usage/UsageStatsManager.STANDBY_BUCKET_RARE,40,Android.App.Usage.StandbyBucket,Rare,remove, E,30,android/app/usage/UsageStatsManager.STANDBY_BUCKET_RESTRICTED,45,Android.App.Usage.UsageStatsInterval,Restricted,remove, E,28,android/app/usage/UsageStatsManager.STANDBY_BUCKET_WORKING_SET,20,Android.App.Usage.StandbyBucket,WorkingSet,remove, `STANDBY_BUCKET_RESTRICTED` should have been added to `StandbyBucket` instead of `UsageStatsInterval`. To fix this in a backwards-compatible way, we can add it to both enums: E,30,android/app/usage/UsageStatsManager.STANDBY_BUCKET_RESTRICTED,45,Android.App.Usage.StandbyBucket,Restricted,remove, A,30,,45,Android.App.Usage.UsageStatsInterval,Restricted,remove, However, we have no way to mark `UsageStatsInterval.Restricted` as `[Obsolete]`, so people may still unintentionally use it. Add a new field to our csv that allows us to set a constant's `@deprecated-since` field, the `30` at the end: A,30,,45,Android.App.Usage.UsageStatsInterval,Restricted,remove,,30 This allows us to generate: [global::System.Runtime.Versioning.ObsoletedOSPlatform ("android30.0")] Restricted = 45 Additionally, when the cause is that we accidentally added an invalid value to the enum, we should provide a better obsolete message, letting the user know that the value will not function. This is done by setting `@deprecated-since` to `-1`: A,30,,45,Android.App.Usage.UsageStatsInterval,Restricted,remove,,-1 resulting in: [global::System.Obsolete (@"This value was incorrectly added to the enumeration and is not a valid value")] Restricted = 45 [0]: https://github.com/xamarin/xamarin-android/blob/cc70ce20aff6934532a8cb6a7bddbf3710fd7e1c/src/Mono.Android/map.csv
- Loading branch information
Showing
7 changed files
with
103 additions
and
10 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
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