Commit d6024f1
[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.1 parent 3968236 commit d6024f1
File tree
3 files changed
+153
-8
lines changed- tests/generator-Tests/Unit-Tests
- tools/generator/Java.Interop.Tools.Generator.Importers
3 files changed
+153
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
22 | 51 | | |
23 | 52 | | |
24 | 53 | | |
| |||
28 | 57 | | |
29 | 58 | | |
30 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
31 | 78 | | |
32 | 79 | | |
33 | 80 | | |
| 81 | + | |
34 | 82 | | |
35 | | - | |
| 83 | + | |
36 | 84 | | |
37 | 85 | | |
38 | 86 | | |
39 | 87 | | |
40 | 88 | | |
41 | 89 | | |
42 | 90 | | |
| 91 | + | |
43 | 92 | | |
44 | | - | |
| 93 | + | |
45 | 94 | | |
46 | 95 | | |
47 | 96 | | |
48 | 97 | | |
49 | 98 | | |
50 | 99 | | |
51 | 100 | | |
| 101 | + | |
52 | 102 | | |
53 | | - | |
| 103 | + | |
54 | 104 | | |
55 | 105 | | |
56 | 106 | | |
57 | 107 | | |
58 | 108 | | |
59 | 109 | | |
60 | 110 | | |
| 111 | + | |
61 | 112 | | |
62 | | - | |
| 113 | + | |
63 | 114 | | |
64 | 115 | | |
65 | 116 | | |
66 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
67 | 138 | | |
68 | 139 | | |
69 | 140 | | |
| |||
73 | 144 | | |
74 | 145 | | |
75 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
76 | 176 | | |
77 | 177 | | |
78 | 178 | | |
| |||
91 | 191 | | |
92 | 192 | | |
93 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
94 | 212 | | |
95 | 213 | | |
96 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
| 174 | + | |
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| |||
Lines changed: 30 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
42 | | - | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| 60 | + | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| |||
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
| 96 | + | |
| 97 | + | |
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
96 | | - | |
| 101 | + | |
97 | 102 | | |
98 | 103 | | |
| 104 | + | |
99 | 105 | | |
100 | 106 | | |
101 | 107 | | |
| |||
124 | 130 | | |
125 | 131 | | |
126 | 132 | | |
| 133 | + | |
| 134 | + | |
127 | 135 | | |
128 | 136 | | |
129 | 137 | | |
| |||
205 | 213 | | |
206 | 214 | | |
207 | 215 | | |
| 216 | + | |
| 217 | + | |
208 | 218 | | |
209 | 219 | | |
210 | 220 | | |
| |||
216 | 226 | | |
217 | 227 | | |
218 | 228 | | |
219 | | - | |
| 229 | + | |
220 | 230 | | |
221 | 231 | | |
222 | 232 | | |
| |||
232 | 242 | | |
233 | 243 | | |
234 | 244 | | |
| 245 | + | |
235 | 246 | | |
236 | 247 | | |
237 | 248 | | |
| |||
279 | 290 | | |
280 | 291 | | |
281 | 292 | | |
| 293 | + | |
| 294 | + | |
282 | 295 | | |
283 | 296 | | |
284 | 297 | | |
| |||
350 | 363 | | |
351 | 364 | | |
352 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
353 | 380 | | |
354 | 381 | | |
355 | 382 | | |
| |||
0 commit comments