-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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.
- Loading branch information
Showing
3 changed files
with
153 additions
and
8 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