You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[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
0 commit comments