-
Notifications
You must be signed in to change notification settings - Fork 533
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
.NET 6 Bindings: "Deprecated since" with Obsolete
; UnsupportedOSPlatform
#6349
Comments
The way this is handled in pre-NET6 is that we ship 10+ versions on For example, it would not be marked as You are correct that we do not have a good way to represent this in .NET 6, since we are only shipping a single But likely users will just have to live with the For If you are trying to do (c) for your own library, you can add Example:
Any string you put there will be placed in front of the method declaration. Note the value is an opaque string that |
Thank you for the detailed insight! Obsoletion per dll, targeting a specific API level... interesting! This could work for me as well, but alas this is more of a runtime decision than a compile time decision. So as you say we just don't have anything in .NET 6 for now. Neither Xamarin itself, nor third parties. I agree with the point that devs will want to be nudged towards getting rid of the obsolete API by already showing it as deprecated. To allow folks to run with
Thanks for asking around on that one - curious if this is something that's on the radar at all yet.
Good point. I don't think there actually is any API that was removed, however a few I encountered have been changed to no longer return any useful value, or even throw now. They're rare, but they exist for sure and those might be candidates for such an API annotation. Then again, they are there, you can call them - I guess it would be wrong by Xamarin to mark the API as unavailable. My own goal here is to bind a few AOSP OEM APIs (among other things), and they do in fact remove those after a while (sometimes right away - without a grace deprecation period). For that |
I don't think there's much more for us to do here. This is on the .NET team now, if they choose to support scenarios like this in the future. |
Issue
I have a native API I'd like to generate bindings for. This API is available in API level
A
, was deprecated inB
and removed inC
. (WithA < B < C
.) What I'm thus looking for is a way to mark the API to beA
and to not be available on earlier API levels.B
.C
.It looks like xamarin/java.interop/#773 added
SupportedOSPlatform
, taking care of (1). I tested this withapi-since="27"
in myMetadata.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 theref
dll):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)
The text was updated successfully, but these errors were encountered: