Commit 28d6905
authored
[generator] Don't mark a method as
Context: 1cfb4f4
@jonathanpeppers [noted][0]:
> MAUI noticed this API says `UnsupportedOSPlatform`:
>
> // Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
> // Android.OS.Bundle
> [UnsupportedOSPlatform("android21.0")]
> [Register("putString", "(Ljava/lang/String;Ljava/lang/String;)V", "")]
> public override void PutString(string? key, string? value) { ... }
In [API-21][1], `android.os.Bundle.putString()` was *moved* to the
new base class [`android.os.BaseBundle`][2].
<class … name="BaseBundle" … merge.SourceFile="..\..\bin\BuildDebug\api\api-21.xml.in">
<method … name="putString" jni-signature="(Ljava/lang/String;Ljava/lang/String;)V" …>
<parameter name="key" type="java.lang.String" jni-type="Ljava/lang/String;"></parameter>
<parameter name="value" type="java.lang.String" jni-type="Ljava/lang/String;"></parameter>
</method>
</class>
…
<class … extends="android.os.BaseBundle" … name="Bundle" …>
<method … name="putString" jni-signature="(Ljava/lang/String;Ljava/lang/String;)V" … removed-since="21">
<parameter name="key" type="java.lang.String" jni-type="Ljava/lang/String;"></parameter>
<parameter name="value" type="java.lang.String" jni-type="Ljava/lang/String;"></parameter>
</method>
</class>
This movement was detected as an API *removal* by `api-merge`,
causing `generator` to emit `[UnsupportedOSPlatform]`:
partial class Bundle {
[UnsupportedOSPlatform("android21.0")]
[Register("putString", "(Ljava/lang/String;Ljava/lang/String;)V", "")]
public override void PutString(string? key, string? value) => …
}
While technically correct that `android.os.Bundle.putString()` was
"removed" in API-21, it was really moved to a base class as
`android.os.BaseBundle.putString()`. We will continue to generate both
methods for binary compatibility, but we should not mark the overriding
method as `[UnsupportedOSPlatform]` because the "supported" base method
is still present.
Fix `generator` to recognize this case and not emit
`[UnsupportedOSPlatform]` here.
With this change, `Android.OS.Bundle.cs` contains:
partial class Bundle {
// Metadata.xml XPath method reference: path="/api/package[@name='android.os']/class[@name='Bundle']/method[@name='putString' and count(parameter)=2 and parameter[1][@type='java.lang.String'] and parameter[2][@type='java.lang.String']]"
[Register ("putString", "(Ljava/lang/String;Ljava/lang/String;)V", "")]
public override unsafe void PutString (string? key, string? value) { ... }
}
[0]: https://discord.com/channels/732297728826277939/732297837953679412/1342558634390982666
[1]: https://developer.android.com/sdk/api_diff/21/changes
[2]: https://developer.android.com/reference/android/os/BaseBundle[UnsupportedOSPlatform] if it overrides a supported base method. (#1313)1 parent 9dea87d commit 28d6905
File tree
2 files changed
+38
-0
lines changed- tests/generator-Tests/Unit-Tests
- tools/generator/Java.Interop.Tools.Generator.ObjectModel
2 files changed
+38
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1436 | 1436 | | |
1437 | 1437 | | |
1438 | 1438 | | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
1439 | 1472 | | |
1440 | 1473 | | |
1441 | 1474 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
326 | 331 | | |
327 | 332 | | |
328 | 333 | | |
| |||
0 commit comments