-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing SupportedOSPlatformAttribute for enum members, const members #1037
Labels
enhancement
Proposed change to current functionality
generator
Issues binding a Java library (generator, class-parse, etc.)
Milestone
Comments
jpobst
added
enhancement
Proposed change to current functionality
generator
Issues binding a Java library (generator, class-parse, etc.)
and removed
needs-triage
labels
Sep 15, 2022
Yep, we should add support for these attributes for |
jonpryor
changed the title
Missing SupportedOSPlatformAttribute for enums
Missing SupportedOSPlatformAttribute for enum members, const members
Sep 15, 2022
ObsoletedInOSPlatformAttribute would also be good to have. |
jonpryor
pushed a commit
that referenced
this issue
Oct 20, 2022
Context: #1037 Currently we do not add `[SupportedOSPlatform]` attributes to bound `const` fields, which can lead to customers using them on platforms where they are not supported: namespace Android.Telecom { public partial class TelecomManager : Java.Lang.Object { [Register("ACTION_POST_CALL", ApiSince=30)] public const string ActionPostCall = "android.telecom.action.POST_CALL"; } } Update `generator` so that `[SupportedOSPlatform]` is emitted for such `const` fields: namespace Android.Telecom { public partial class TelecomManager : Java.Lang.Object { [Register("ACTION_POST_CALL", ApiSince=30)] [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android30.0")] public const string ActionPostCall = "android.telecom.action.POST_CALL"; } } Note this does not address the `enum` part of #1037, which will require a much more involved fix.
jonpryor
pushed a commit
that referenced
this issue
Dec 8, 2022
Context: #1037 Refactor `EnumGenerator` to use `SourceWriters` instead of `TextWriter`. This will make it possible to use our existing code to apply `[PlatformOSSupported]` attributes to enums in a future PR. This is a separate PR to help verify there was no output changed from the refactor.
jonpryor
pushed a commit
that referenced
this issue
Dec 14, 2022
…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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
enhancement
Proposed change to current functionality
generator
Issues binding a Java library (generator, class-parse, etc.)
Android application type
Android for .NET (net6.0-android, etc.)
Affected platform version
VS 2022 17.3.3
Description
In .NET 6 Android the consts are missing
SupportedOSPlatformAttribute
.Examples:
APILevel is already present in RegisterAttribute.ApiSince.
I would also expect that the new enum
VibrationEffectSupport
also has theSupportedOSPlatformAttribute
as the values are only available since API 30.Steps to Reproduce
Create new .NET 6 Android project and use Android consts/enums.
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: