-
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] 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
- Loading branch information
Showing
3 changed files
with
103 additions
and
21 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