@@ -1441,13 +1441,23 @@ public void UnsupportedOSPlatformConstFields ()
14411441 public void UnsupportedOSPlatformIgnoresMethodOverrides ( )
14421442 {
14431443 // Given:
1444+ // Class inheritance scenario:
14441445 // public class TextView {
14451446 // public Object doThing () { ... }
14461447 // }
14471448 // public class TextView2 : TextView {
14481449 // public Object doThing () { ... } // removed-since = 30
14491450 // }
1450- // We should not write [UnsupportedOSPlatform] on TextView2.doThing (), because the base method isn't "removed".
1451+ // Interface inheritance scenario:
1452+ // public interface IFoo {
1453+ // public Object doSomething () { ... }
1454+ // public static final String DATE_TAKEN = "datetaken";
1455+ // }
1456+ // public interface IBar : IFoo {
1457+ // public Object doSomething () { ... } // removed-since = 30
1458+ // public static final String DATE_TAKEN = "datetaken"; // removed-since = 30
1459+ // }
1460+ // We should not write [UnsupportedOSPlatform] on overriding methods or fields, because the base methods/fields aren't "removed".
14511461 var xml = @$ "<api>
14521462 <package name='java.lang' jni-name='java/lang'>
14531463 <class abstract='false' deprecated='not deprecated' final='false' name='Object' static='false' visibility='public' jni-signature='Ljava/lang/Object;' />
@@ -1460,13 +1470,97 @@ public void UnsupportedOSPlatformIgnoresMethodOverrides ()
14601470 <method abstract='false' deprecated='not deprecated' final='false' name='doThing' bridge='false' native='false' return='java.lang.Object' static='false' synchronized='false' synthetic='false' visibility='public' removed-since='30' />
14611471 </class>
14621472 </package>
1473+ <package name='com.example' jni-name='com/example'>
1474+ <interface abstract='true' deprecated='not deprecated' final='false' name='Foo' static='false' visibility='public' jni-signature='Lcom/example/Foo;'>
1475+ <method abstract='true' deprecated='not deprecated' final='false' name='doSomething' bridge='false' native='false' return='java.lang.Object' static='false' synchronized='false' synthetic='false' visibility='public' />
1476+ <field deprecated='not deprecated' final='true' name='DATE_TAKEN' jni-signature='Ljava/lang/String;' static='true' transient='false' type='java.lang.String' type-generic-aware='java.lang.String' value='"datetaken"' visibility='public' volatile='false'></field>
1477+ </interface>
1478+ <interface abstract='true' deprecated='not deprecated' final='false' name='Bar' static='false' visibility='public' jni-signature='Lcom/example/Bar;'>
1479+ <implements name='com.example.Foo' name-generic-aware='com.example.Foo' jni-type='Lcom/example/Foo;'></implements>
1480+ <method abstract='true' deprecated='not deprecated' final='false' name='doSomething' bridge='false' native='false' return='java.lang.Object' static='false' synchronized='false' synthetic='false' visibility='public' removed-since='30' />
1481+ <field deprecated='not deprecated' final='true' name='DATE_TAKEN' jni-signature='Ljava/lang/String;' static='true' transient='false' type='java.lang.String' type-generic-aware='java.lang.String' value='"datetaken"' visibility='public' volatile='false' removed-since='30'></field>
1482+ </interface>
1483+ </package>
1484+ </api>" ;
1485+
1486+ var gens = ParseApiDefinition ( xml ) ;
1487+
1488+ // Test class inheritance scenario
1489+ var klass = gens . Single ( g => g . Name == "TextView2" ) ;
1490+ var actual = GetGeneratedTypeOutput ( klass ) ;
1491+ StringAssert . DoesNotContain ( "[global::System.Runtime.Versioning.UnsupportedOSPlatformAttribute (\" android30.0\" )]" , actual , "Should not contain UnsupportedOSPlatform on class override!" ) ;
1492+
1493+ // Test interface inheritance scenario
1494+ var iface = gens . OfType < InterfaceGen > ( ) . Single ( g => g . Name == "IBar" ) ;
1495+ var ifaceActual = GetGeneratedTypeOutput ( iface ) ;
1496+ StringAssert . DoesNotContain ( "[global::System.Runtime.Versioning.UnsupportedOSPlatformAttribute (\" android30.0\" )]" , ifaceActual , "Should not contain UnsupportedOSPlatform on interface override!" ) ;
1497+ }
1498+
1499+ [ Test ]
1500+ public void UnsupportedOSPlatformIgnoresPropertyOverrides ( )
1501+ {
1502+ // Given:
1503+ // Class inheritance scenario:
1504+ // public class TextView {
1505+ // public Object getThing () { ... }
1506+ // public void setThing (Object value) { ... }
1507+ // }
1508+ // public class TextView2 : TextView {
1509+ // public Object getThing () { ... } // removed-since = 30
1510+ // public void setThing (Object value) { ... } // removed-since = 30
1511+ // }
1512+ // Interface inheritance scenario:
1513+ // public interface IPropertyProvider {
1514+ // public Object getSomething () { ... }
1515+ // public static final String DATE_TAKEN = "datetaken";
1516+ // }
1517+ // public interface IExtendedProvider : IPropertyProvider {
1518+ // public Object getSomething () { ... } // removed-since = 30
1519+ // public static final String DATE_TAKEN = "datetaken"; // removed-since = 30
1520+ // }
1521+ // We should not write [UnsupportedOSPlatform] on overriding properties or fields, because the base methods/fields aren't "removed".
1522+ var xml = @$ "<api>
1523+ <package name='java.lang' jni-name='java/lang'>
1524+ <class abstract='false' deprecated='not deprecated' final='false' name='Object' static='false' visibility='public' jni-signature='Ljava/lang/Object;' />
1525+ </package>
1526+ <package name='android.widget' jni-name='android/widget'>
1527+ <class abstract='false' deprecated='not deprecated' extends='java.lang.Object' extends-generic-aware='java.lang.Object' final='false' name='TextView' static='false' visibility='public'>
1528+ <method abstract='false' deprecated='not deprecated' final='false' name='getThing' bridge='false' native='false' return='java.lang.Object' static='false' synchronized='false' synthetic='false' visibility='public' />
1529+ <method abstract='false' deprecated='not deprecated' final='false' name='setThing' bridge='false' native='false' return='void' static='false' synchronized='false' synthetic='false' visibility='public'>
1530+ <parameter name='value' type='java.lang.Object' />
1531+ </method>
1532+ </class>
1533+ <class abstract='false' deprecated='not deprecated' extends='android.widget.TextView' extends-generic-aware='java.lang.Object' final='false' name='TextView2' static='false' visibility='public'>
1534+ <method abstract='false' deprecated='not deprecated' final='false' name='getThing' bridge='false' native='false' return='java.lang.Object' static='false' synchronized='false' synthetic='false' visibility='public' removed-since='30' />
1535+ <method abstract='false' deprecated='not deprecated' final='false' name='setThing' bridge='false' native='false' return='void' static='false' synchronized='false' synthetic='false' visibility='public' removed-since='30'>
1536+ <parameter name='value' type='java.lang.Object' />
1537+ </method>
1538+ </class>
1539+ </package>
1540+ <package name='com.example' jni-name='com/example'>
1541+ <interface abstract='true' deprecated='not deprecated' final='false' name='PropertyProvider' static='false' visibility='public' jni-signature='Lcom/example/PropertyProvider;'>
1542+ <method abstract='true' deprecated='not deprecated' final='false' name='getSomething' bridge='false' native='false' return='java.lang.Object' static='false' synchronized='false' synthetic='false' visibility='public' />
1543+ <field deprecated='not deprecated' final='true' name='DATE_TAKEN' jni-signature='Ljava/lang/String;' static='true' transient='false' type='java.lang.String' type-generic-aware='java.lang.String' value='"datetaken"' visibility='public' volatile='false'></field>
1544+ </interface>
1545+ <interface abstract='true' deprecated='not deprecated' final='false' name='ExtendedProvider' static='false' visibility='public' jni-signature='Lcom/example/ExtendedProvider;'>
1546+ <implements name='com.example.PropertyProvider' name-generic-aware='com.example.PropertyProvider' jni-type='Lcom/example/PropertyProvider;'></implements>
1547+ <method abstract='true' deprecated='not deprecated' final='false' name='getSomething' bridge='false' native='false' return='java.lang.Object' static='false' synchronized='false' synthetic='false' visibility='public' removed-since='30' />
1548+ <field deprecated='not deprecated' final='true' name='DATE_TAKEN' jni-signature='Ljava/lang/String;' static='true' transient='false' type='java.lang.String' type-generic-aware='java.lang.String' value='"datetaken"' visibility='public' volatile='false' removed-since='30'></field>
1549+ </interface>
1550+ </package>
14631551 </api>" ;
14641552
14651553 var gens = ParseApiDefinition ( xml ) ;
1554+
1555+ // Test class inheritance scenario
14661556 var klass = gens . Single ( g => g . Name == "TextView2" ) ;
14671557 var actual = GetGeneratedTypeOutput ( klass ) ;
1558+ StringAssert . DoesNotContain ( "[global::System.Runtime.Versioning.UnsupportedOSPlatformAttribute (\" android30.0\" )]" , actual , "Should not contain UnsupportedOSPlatform on class property override!" ) ;
14681559
1469- StringAssert . DoesNotContain ( "[global::System.Runtime.Versioning.UnsupportedOSPlatformAttribute (\" android30.0\" )]" , actual , "Should contain UnsupportedOSPlatform!" ) ;
1560+ // Test interface inheritance scenario
1561+ var iface = gens . OfType < InterfaceGen > ( ) . Single ( g => g . Name == "IExtendedProvider" ) ;
1562+ var ifaceActual = GetGeneratedTypeOutput ( iface ) ;
1563+ StringAssert . DoesNotContain ( "[global::System.Runtime.Versioning.UnsupportedOSPlatformAttribute (\" android30.0\" )]" , ifaceActual , "Should not contain UnsupportedOSPlatform on interface property override!" ) ;
14701564 }
14711565
14721566 [ Test ]
0 commit comments