-
Notifications
You must be signed in to change notification settings - Fork 565
Description
Issue
I have a native API I'd like to generate bindings for. This API is available in API level A, was deprecated in B and removed in C. (With A < B < C.) What I'm thus looking for is a way to mark the API to be
- introduced in API level
Aand to not be available on earlier API levels. - deprecated in API level
B. - not available starting with API level
C.
It looks like xamarin/java.interop/#773 added SupportedOSPlatform, taking care of (1). I tested this with api-since="27" in my Metadata.xml and it works without issues 🎉
But for APIs that are deprecated only starting in a specific API level, it looks like the bindings generation process is not able to add anything to the generated output to tell the bindings consumer about the API level the API is deprecated in.
Here's an example:
DevicePolicyManager.ClearDeviceOwnerApp was introduced in API level 21 and deprecated in 26. Currently, the Xamarin.Android bindings ship with this (decompiled from the ref dll):
[Obsolete("deprecated")]
[Register("clearDeviceOwnerApp", "(Ljava/lang/String;)V", "GetClearDeviceOwnerApp_Ljava_lang_String_Handler")]
public virtual void ClearDeviceOwnerApp(string packageName)
{
throw null;
}Note that it just marks it as deprecated, with no way to figure out that it's actually available just fine if you target any version in [21, 26). So it seems like (2) cannot be handled currently. I'm not aware of anything in the .NET tooling to allow this, but I figured it's worth asking if there is a way.
For (3) I wonder if it's possible for the generator to add UnsupportedOSPlatform on a generated symbol. Just like support for SupportedOSPlatform was added already.
Version Information
VS 2022 (Version 17.0.0 Preview 4.1)
.NET 6 (6.0.100-rc.1.21463.6)