-
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
15 changed files
with
446 additions
and
0 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
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
...Gen-Binding/Xamarin.Android.DefaultInterfaceMethods-Lib/Jars/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.test; | ||
|
||
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
.../CodeGen-Binding/Xamarin.Android.DefaultInterfaceMethods-Lib/Jars/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.test; | ||
|
||
public class EmptyOverrideClass implements DefaultMethodsInterface | ||
{ | ||
} |
18 changes: 18 additions & 0 deletions
18
...en-Binding/Xamarin.Android.DefaultInterfaceMethods-Lib/Jars/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.test; | ||
|
||
public class ImplementedOverrideClass implements DefaultMethodsInterface | ||
{ | ||
@Override | ||
public int foo () { | ||
return 6; | ||
} | ||
|
||
@Override | ||
public int getBar () { | ||
return 100; | ||
} | ||
|
||
@Override | ||
public void setBar (int value) { | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
...in.Android.DefaultInterfaceMethods-Lib/Xamarin.Android.DefaultInterfaceMethods-Lib.csproj
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,75 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{D360FDF3-F1CE-4698-9351-CC9D4502DF5C}</ProjectGuid> | ||
<ProjectTypeGuids>{10368E6C-D01B-4462-8E8B-01FC667A7035};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<TemplateGuid>{77efb91c-a7e9-4b0e-a7c5-31eeec3c6d46}</TemplateGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Xamarin.Android.DefaultInterfaceMethods_Lib</RootNamespace> | ||
<AssemblyName>Xamarin.Android.DefaultInterfaceMethods-Lib</AssemblyName> | ||
<FileAlignment>512</FileAlignment> | ||
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk> | ||
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion> | ||
<AndroidClassParser>class-parse</AndroidClassParser> | ||
<AndroidCodegenTarget>XAJavaInterop1</AndroidCodegenTarget> | ||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> | ||
<LangVersion>preview</LangVersion> | ||
<EnableInterfaceMembersPreview>True</EnableInterfaceMembersPreview> | ||
<_JavacSourceVersion>1.8</_JavacSourceVersion> | ||
<_JavacTargetVersion>1.8</_JavacTargetVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>portable</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>portable</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Mono.Android" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
</ItemGroup> | ||
<ItemDefinitionGroup> | ||
<TestJarEntry> | ||
<OutputFile>Jars/dim-test.jar</OutputFile> | ||
</TestJarEntry> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<TestJarEntry Include="Jars\ImplementedOverrideClass.java" /> | ||
<TestJarEntry Include="Jars\EmptyOverrideClass.java" /> | ||
<TestJarEntry Include="Jars\DefaultMethodsInterface.java" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedJar Include="Jars/dim-test.jar" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" /> | ||
<Import Project="..\..\..\build-tools\scripts\Jar.targets" /> | ||
<PropertyGroup> | ||
<BuildDependsOn> | ||
BuildTestJarFile; | ||
$(BuildDependsOn) | ||
</BuildDependsOn> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<CleanDependsOn> | ||
CleanTestJarFile; | ||
$(CleanDependsOn); | ||
</CleanDependsOn> | ||
</PropertyGroup> | ||
</Project> |
39 changes: 39 additions & 0 deletions
39
tests/CodeGen-Binding/Xamarin.Android.DefaultInterfaceMethods-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,39 @@ | ||
using System; | ||
using Com.Xamarin.Test; | ||
using Java.Lang; | ||
using NUnit.Framework; | ||
|
||
namespace Xamarin.Android.DefaultInterfaceMethodsTests | ||
{ | ||
[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 ()); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/CodeGen-Binding/Xamarin.Android.DefaultInterfaceMethods-Tests/MainActivity.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,18 @@ | ||
using Android.App; | ||
using Android.OS; | ||
using Xamarin.Android.NUnitLite; | ||
using System.Reflection; | ||
|
||
namespace Xamarin.Android.DefaultInterfaceMethods_Tests | ||
{ | ||
[Activity (Label = "Xamarin.Android.DefaultInterfaceMethods-Tests", MainLauncher = true)] | ||
public class MainActivity : TestSuiteActivity | ||
{ | ||
protected override void OnCreate (Bundle savedInstanceState) | ||
{ | ||
AddTest (Assembly.GetExecutingAssembly ()); | ||
|
||
base.OnCreate (savedInstanceState); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...eGen-Binding/Xamarin.Android.DefaultInterfaceMethods-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="xamarin.android.defaultinterfacemethods_tests" android:installLocation="auto"> | ||
<uses-sdk android:minSdkVersion="28" android:targetSdkVersion="28" /> | ||
<application android:allowBackup="true" android:label="DimTests" android:supportsRtl="true"></application> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
</manifest> |
30 changes: 30 additions & 0 deletions
30
.../CodeGen-Binding/Xamarin.Android.DefaultInterfaceMethods-Tests/Properties/AssemblyInfo.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,30 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using Android.App; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Xamarin.Android.DefaultInterfaceMethods_Tests")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Xamarin.Android.DefaultInterfaceMethods_Tests")] | ||
[assembly: AssemblyCopyright("Copyright © 2018")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
[assembly: ComVisible(false)] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
24 changes: 24 additions & 0 deletions
24
tests/CodeGen-Binding/Xamarin.Android.DefaultInterfaceMethods-Tests/TestInstrumentation.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,24 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
using Android.App; | ||
using Android.Runtime; | ||
using Xamarin.Android.NUnitLite; | ||
|
||
namespace Xamarin.Android.DefaultInterfaceMethods_Tests | ||
{ | ||
[Instrumentation (Name="xamarin.android.dimtests.TestInstrumentation")] | ||
public class TestInstrumentation : TestSuiteInstrumentation { | ||
|
||
public TestInstrumentation (IntPtr handle, JniHandleOwnership transfer) | ||
: base (handle, transfer) | ||
{ | ||
} | ||
|
||
protected override void AddTests () | ||
{ | ||
AddTest (Assembly.GetExecutingAssembly ()); | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.