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] Obsolete&SupportedOSPlatform attributes on enum members (#1066)
Fixes: #1037
Adds support for emitting `[Obsolete]`, `[ObsoletedOSPlatform]`, and
`[SupportedOSPlatform]` custom attributes on enum members.
~~ [SupportedOSPlatform] ~~
The data for `[SupportedOSPlatform]` comes from the values provided
in the enum-mapping file (b00e644), e.g.
[`xamarin-android/src/Mono.Android/map.csv`][0]:
// src/Mono.Android/map.csv
E,29,android/media/MediaRecorder$AudioEncoder.OPUS,7,Android.Media.AudioEncoder,Opus,keep,
The `29` is the API in which we added the enum, which becomes
`[SupportedOSPlatform("android-29.0")]`.
~~ [Obsolete] and [ObsoletedOSPlatform] ~~
The data for the "obsolete" attributes comes from the `deprecated`
and `deprecated-since` attributes on the original field in the
`api.xml`, if it can be found. For example, given:
<class name="AccessibilityServiceInfo" jni-signature="Landroid/accessibilityservice/AccessibilityServiceInfo;" …>
<field
deprecated="deprecated"
final="true"
name="CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY"
jni-signature="I"
static="true"
transient="false"
type="int"
type-generic-aware="int"
value="4"
visibility="public"
volatile="false"
deprecated-since="26"
/>
</class>
in combination with these `map.csv` (b00e644) entries:
A,0,,0,Android.AccessibilityServices.AccessibilityServiceCapabilities,None,remove,
E,18,android/accessibilityservice/AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY,4,Android.AccessibilityServices.AccessibilityServiceCapabilities,CanRequestEnhancedWebAccessibility,remove,
results in:
/* partial */ enum AccessibilityServiceCapabilities {
// When using classic obsolete attributes:
[global::System.Obsolete("deprecated")]
// When using new obsolete attributes:
[global::System.Runtime.Versioning.ObsoletedOSPlatform("android31.0")]
CanRequestEnhancedWebAccessibility = 4,
}
One wrinkle is we may have obsoleted the field because we want the
user to use the enum instead:
<field
deprecated='This constant will be removed in the future version. Use Android.App.RecentTaskFlags enum directly instead of this field.'
name='RECENT_IGNORE_UNAVAILABLE'
…
/>
We need to detect this message and not obsolete the enum in this case.
[0]: https://github.com/xamarin/xamarin-android/blob/17213ea184e23a9020451b265fec459558278489/src/Mono.Android/map.csv
<field deprecated='This constant will be removed in the future version. Use Android.App.RecentTaskFlags enum directly instead of this field.' final='true' name='RECENT_IGNORE_UNAVAILABLE' jni-signature='Ljava/lang/String;' static='true' transient='false' type='java.lang.String' type-generic-aware='java.lang.String' value='"android.permission.BIND_CHOOSER_TARGET_SERVICE"' visibility='public' volatile='false' deprecated-since='31' api-since='30' />
0 commit comments