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] Use //*/@api-since for RegisterAttribute.ApiSince (#644)
Context: 005e273
Currently, if `generator --apiversions=FILE` is used, then the
`RegisterAttribute.ApiSince` field will be set to contain the API
version which introduced a method, e.g. when building xamarin-android's
`src/Mono.Android`:
$ generator.exe --apiversions=$HOME/android-toolchain/sdk/platform-tools/api/api-versions.xml …
and `$HOME/android-toolchain/sdk/platform-tools/api/api-versions.xml`
contains:
<class name="android/view/inspector/IntFlagMapping" since="29">
<extends name="java/lang/Object"/>
then `generator` will emit:
[Register ("android/view/inspector/IntFlagMapping", DoNotGenerateAcw=true, ApiSince=29)]
partial class IntFlagMapping {}
Unfortunately, we have found that Google's support of this file isn't
guaranteed. Sometimes it is missing, other times it changes in
unexpected ways, causing `ApiCompat` breakage within xamarin-android.
In short, we have lost faith in `api-versions.xml`.
Instead of using `api-versions.xml`, allow `RegisterAttribute.ApiSince`
to be populated by a new `//@api-since` attribute, which is now honored
on `package`, `class`/`interface`, `method`, and `field` elements:
<field name='VERSION_CODE' api-since='7' />
This allows it to be set via `metadata` or any external tooling that
modifies `api.xml`.
Note that members will inherit versions from parent types and parent
package definitions, but can also override them as necessary. For
example a package added in API-7 containing a class added in API-9:
<package name='com.example.test' jni-name='com/example/test' api-since='7'>
<class name='MyClassFrom7' />
<class name='MyClassFrom9' api-since='9' />
</package>
As previously, this feature is probably only useful for
`Mono.Android.dll` purposes, but it is now more accessible.
0 commit comments