-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] Add MSBuild support for DIM.
- Loading branch information
Showing
12 changed files
with
261 additions
and
2 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
95 changes: 95 additions & 0 deletions
95
tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/DimBindingTests.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using System; | ||
using Com.Xamarin.Android; | ||
using Java.Lang; | ||
using NUnit.Framework; | ||
|
||
namespace Xamarin.Android.JcwGenTests | ||
{ | ||
[TestFixture] | ||
public class DimTest | ||
{ | ||
[Test] | ||
public void TestDefaultInterfaceMethods () | ||
{ | ||
var empty = new EmptyOverrideClass (); | ||
var iface = empty as IDefaultMethodsInterface; | ||
|
||
Assert.AreEqual (0, iface.Foo ()); | ||
Assert.AreEqual (2, iface.Bar); | ||
Assert.DoesNotThrow (() => iface.Bar = 5); | ||
|
||
Assert.AreEqual (0, iface.InvokeFoo ()); | ||
|
||
Assert.Throws<UnsupportedOperationException> (() => iface.ToImplement ()); | ||
} | ||
|
||
[Test] | ||
public void TestOverriddenDefaultInterfaceMethods () | ||
{ | ||
var over = new ImplementedOverrideClass (); | ||
var iface = over as IDefaultMethodsInterface; | ||
|
||
Assert.AreEqual (6, over.Foo ()); | ||
Assert.AreEqual (100, over.Bar); | ||
Assert.DoesNotThrow (() => over.Bar = 5); | ||
|
||
Assert.AreEqual (6, iface.InvokeFoo ()); | ||
} | ||
|
||
[Test] | ||
public void TestManagedEmptyDefaultInterfaceMethods () | ||
{ | ||
// Test using empty C# implementing interface | ||
var empty = new ManagedEmptyDefault (); | ||
var iface = empty as IDefaultMethodsInterface; | ||
|
||
Assert.AreEqual (0, iface.Foo ()); | ||
|
||
Assert.AreEqual (0, iface.InvokeFoo ()); | ||
} | ||
|
||
[Test] | ||
public void TestManagedOverriddenDefaultInterfaceMethods () | ||
{ | ||
// Test using method overridden in C# | ||
var over = new ManagedOverrideDefault (); | ||
var iface = over as IDefaultMethodsInterface; | ||
|
||
Assert.AreEqual (15, over.Foo ()); | ||
Assert.AreEqual (15, iface.Foo ()); | ||
|
||
Assert.AreEqual (15, iface.InvokeFoo ()); | ||
} | ||
|
||
[Test] | ||
public void TestStaticMethods () | ||
{ | ||
Assert.AreEqual (10, IStaticMethodsInterface.Foo ()); | ||
|
||
Assert.AreEqual (3, IStaticMethodsInterface.Value); | ||
Assert.DoesNotThrow (() => IStaticMethodsInterface.Value = 5); | ||
} | ||
|
||
[Test] | ||
public void TestChainedDefaultInterfaceMethods () | ||
{ | ||
var over = new ImplementedChainOverrideClass (); | ||
var iface = over as IDefaultMethodsInterface; | ||
|
||
Assert.AreEqual (6, over.Foo ()); | ||
Assert.AreEqual (100, over.Bar); | ||
Assert.DoesNotThrow (() => over.Bar = 5); | ||
|
||
Assert.AreEqual (6, iface.InvokeFoo ()); | ||
} | ||
|
||
class ManagedEmptyDefault : Java.Lang.Object, IDefaultMethodsInterface | ||
{ | ||
} | ||
|
||
class ManagedOverrideDefault : Java.Lang.Object, IDefaultMethodsInterface | ||
{ | ||
public int Foo () => 15; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Properties/AndroidManifest.xml
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
10 changes: 10 additions & 0 deletions
10
...inding/Xamarin.Android.McwGen-Tests/java/com/xamarin/android/DefaultMethodsInterface.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.xamarin.android; | ||
|
||
public interface DefaultMethodsInterface | ||
{ | ||
default int foo () { return 0; } | ||
default int getBar () { return 2; } | ||
default void setBar (int value) { } | ||
default int toImplement () { throw new UnsupportedOperationException (); } | ||
default int invokeFoo () { return foo (); } | ||
} |
5 changes: 5 additions & 0 deletions
5
...Gen-Binding/Xamarin.Android.McwGen-Tests/java/com/xamarin/android/EmptyOverrideClass.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.xamarin.android; | ||
|
||
public class EmptyOverrideClass implements DefaultMethodsInterface | ||
{ | ||
} |
18 changes: 18 additions & 0 deletions
18
.../Xamarin.Android.McwGen-Tests/java/com/xamarin/android/ImplementedChainOverrideClass.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.xamarin.android; | ||
|
||
public class ImplementedChainOverrideClass extends EmptyOverrideClass | ||
{ | ||
@Override | ||
public int foo () { | ||
return 6; | ||
} | ||
|
||
@Override | ||
public int getBar () { | ||
return 100; | ||
} | ||
|
||
@Override | ||
public void setBar (int value) { | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...nding/Xamarin.Android.McwGen-Tests/java/com/xamarin/android/ImplementedOverrideClass.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.xamarin.android; | ||
|
||
public class ImplementedOverrideClass implements DefaultMethodsInterface | ||
{ | ||
@Override | ||
public int foo () { | ||
return 6; | ||
} | ||
|
||
@Override | ||
public int getBar () { | ||
return 100; | ||
} | ||
|
||
@Override | ||
public void setBar (int value) { | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...Binding/Xamarin.Android.McwGen-Tests/java/com/xamarin/android/StaticMethodsInterface.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.xamarin.android; | ||
|
||
public interface StaticMethodsInterface | ||
{ | ||
static int foo () { return 10; } | ||
static int getValue () { return 3; } | ||
static void setValue (int value) { } | ||
} |