Skip to content

Commit 0aec86a

Browse files
authored
[generator-Tests] Enable JavaInterop1 Integration output tests (#1271)
Remaining Integration-Tests which don't support JavaInterop1: * Use of `Android.Runtime.GeneratedEnumAttribute`: CS0234: The type or namespace name 'GeneratedEnumAttribute' does not exist in the namespace 'Android.Runtime' Impacts: Core_Jar2Xml.cs * Use of `Android.Runtime.RegisterAttribute` on `*Implementor` types, probable missing event handler support: CS0234: The type or namespace name 'RegisterAttribute' does not exist in the namespace 'Android.Runtime' [Register ("mono/com/google/android/exoplayer/drm/ExoMediaDrm_OnEventListenerImplementor")] internal sealed partial class IExoMediaDrmOnEventListenerImplementor : global::Java.Lang.Object, IExoMediaDrmOnEventListener Impacts: GenericArguments.cs * Missing builtin mapping between collection types: warning BG8800: Unknown parameter type 'java.util.List<java.lang.Integer>' for member … warning BG8800: Unknown parameter type 'java.util.ArrayList<java.lang.Integer>' for member warning BG8400: Unexpected field type `java.util.List<java.lang.String>` Impacts: Java_Util_List.cs, NormalMethods.cs, ParameterXPath.cs * `Handle` isn't a public property in JavaInterop1, resulting in warning CS0109: CS0109: The member 'SomeObject.Handle(Object, Throwable)' does not hide an accessible member. The new keyword is not required. Impacts: NormalMethods.cs * Use of `JNIEnv.GetJniName()` string __id = "(L" + global::Android.Runtime.JNIEnv.GetJniName (GetType ().DeclaringType) + ";)V"; Impacts: NestedTypes.cs
1 parent 2a1e180 commit 0aec86a

12 files changed

+152
-18
lines changed

tests/generator-Tests/Integration-Tests/Adapters.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace generatortests
66
[TestFixture]
77
public class Adapters : BaseGeneratorTest
88
{
9-
protected override bool TryJavaInterop1 => false;
9+
protected override bool TryJavaInterop1 => true;
1010

1111
[Test]
1212
public void GeneratedOK ()

tests/generator-Tests/Integration-Tests/Java_Lang_Enum.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace generatortests
66
[TestFixture]
77
public class Java_Lang_Enum : BaseGeneratorTest
88
{
9-
protected override bool TryJavaInterop1 => false;
9+
protected override bool TryJavaInterop1 => true;
1010

1111
[Test]
1212
public void Generated_OK ()

tests/generator-Tests/expected.ji/Adapters/Java.Lang.Object.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by a tool.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
#nullable restore
111
using System;
212
using System.Collections.Generic;
313
using Java.Interop;

tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AbsSpinner.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by a tool.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
#nullable restore
111
using System;
212
using System.Collections.Generic;
313
using Java.Interop;
@@ -64,20 +74,19 @@ public AbsSpinnerInvoker (ref JniObjectReference reference, JniObjectReferenceOp
6474
const string __id = "getAdapter.()Lxamarin/test/Adapter;";
6575
try {
6676
var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null);
67-
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::global::Java.Lang.Object>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
77+
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.Object>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
6878
} finally {
6979
}
7080
}
7181
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='T']]"
7282
set {
7383
const string __id = "setAdapter.(Lxamarin/test/Adapter;)V";
74-
IntPtr native_value = JNIEnv.ToLocalJniHandle (value);
84+
var native_value = (value?.PeerReference ?? default);
7585
try {
7686
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
7787
__args [0] = new JniArgumentValue (native_value);
7888
_members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args);
7989
} finally {
80-
JNIEnv.DeleteLocalRef (native_value);
8190
global::System.GC.KeepAlive (value);
8291
}
8392
}

tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.AdapterView.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by a tool.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
#nullable restore
111
using System;
212
using System.Collections.Generic;
313
using Java.Interop;
@@ -22,11 +32,11 @@ protected AdapterView (ref JniObjectReference reference, JniObjectReferenceOptio
2232

2333
protected abstract global::Java.Lang.Object RawAdapter {
2434
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='getAdapter' and count(parameter)=0]"
25-
[Register ("getAdapter", "()Lxamarin/test/Adapter;", "GetGetAdapterHandler")]
35+
[global::Java.Interop.JniMethodSignature ("getAdapter", "()Lxamarin/test/Adapter;")]
2636
get;
2737

2838
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='T']]"
29-
[Register ("setAdapter", "(Lxamarin/test/Adapter;)V", "GetSetAdapter_Lxamarin_test_Adapter_Handler")]
39+
[global::Java.Interop.JniMethodSignature ("setAdapter", "(Lxamarin/test/Adapter;)V")]
3040
set;
3141
}
3242

@@ -52,20 +62,19 @@ public AdapterViewInvoker (ref JniObjectReference reference, JniObjectReferenceO
5262
const string __id = "getAdapter.()Lxamarin/test/Adapter;";
5363
try {
5464
var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null);
55-
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::global::Java.Lang.Object>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
65+
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.Object>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
5666
} finally {
5767
}
5868
}
5969
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='T']]"
6070
set {
6171
const string __id = "setAdapter.(Lxamarin/test/Adapter;)V";
62-
IntPtr native_value = JNIEnv.ToLocalJniHandle (value);
72+
var native_value = (value?.PeerReference ?? default);
6373
try {
6474
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
6575
__args [0] = new JniArgumentValue (native_value);
6676
_members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args);
6777
} finally {
68-
JNIEnv.DeleteLocalRef (native_value);
6978
global::System.GC.KeepAlive (value);
7079
}
7180
}

tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.GenericReturnObject.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by a tool.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
#nullable restore
111
using System;
212
using System.Collections.Generic;
313
using Java.Interop;
@@ -20,6 +30,7 @@ protected GenericReturnObject (ref JniObjectReference reference, JniObjectRefere
2030
}
2131

2232
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='GenericReturnObject']/method[@name='GenericReturn' and count(parameter)=0]"
33+
[global::Java.Interop.JniMethodSignature ("GenericReturn", "()Lxamarin/test/AdapterView;")]
2334
public virtual unsafe global::Xamarin.Test.AdapterView GenericReturn ()
2435
{
2536
const string __id = "GenericReturn.()Lxamarin/test/AdapterView;";

tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,20 @@ namespace Xamarin.Test {
88
[global::Java.Interop.JniTypeSignature ("xamarin/test/Adapter", GenerateJavaPeer=false)]
99
public partial interface IAdapter : IJavaPeerable {
1010
}
11+
12+
[global::Java.Interop.JniTypeSignature ("xamarin/test/Adapter", GenerateJavaPeer=false)]
13+
internal partial class IAdapterInvoker : global::Java.Lang.Object, IAdapter {
14+
[global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)]
15+
[global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)]
16+
public override global::Java.Interop.JniPeerMembers JniPeerMembers {
17+
get { return _members_xamarin_test_Adapter; }
18+
}
19+
20+
static readonly JniPeerMembers _members_xamarin_test_Adapter = new JniPeerMembers ("xamarin/test/Adapter", typeof (IAdapterInvoker));
21+
22+
public IAdapterInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options)
23+
{
24+
}
25+
26+
}
1127
}

tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,22 @@ namespace Xamarin.Test {
88
[global::Java.Interop.JniTypeSignature ("xamarin/test/SpinnerAdapter", GenerateJavaPeer=false)]
99
public partial interface ISpinnerAdapter : global::Xamarin.Test.IAdapter {
1010
}
11+
12+
[global::Java.Interop.JniTypeSignature ("xamarin/test/SpinnerAdapter", GenerateJavaPeer=false)]
13+
internal partial class ISpinnerAdapterInvoker : global::Java.Lang.Object, ISpinnerAdapter {
14+
[global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)]
15+
[global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)]
16+
public override global::Java.Interop.JniPeerMembers JniPeerMembers {
17+
get { return _members_xamarin_test_SpinnerAdapter; }
18+
}
19+
20+
static readonly JniPeerMembers _members_xamarin_test_Adapter = new JniPeerMembers ("xamarin/test/Adapter", typeof (ISpinnerAdapterInvoker));
21+
22+
static readonly JniPeerMembers _members_xamarin_test_SpinnerAdapter = new JniPeerMembers ("xamarin/test/SpinnerAdapter", typeof (ISpinnerAdapterInvoker));
23+
24+
public ISpinnerAdapterInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options)
25+
{
26+
}
27+
28+
}
1129
}

tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Enum.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by a tool.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
#nullable restore
111
using System;
212
using System.Collections.Generic;
313
using Java.Interop;
@@ -21,17 +31,17 @@ protected Enum (ref JniObjectReference reference, JniObjectReferenceOptions opti
2131
}
2232

2333
// Metadata.xml XPath method reference: path="/api/package[@name='java.lang']/class[@name='Enum']/method[@name='compareTo' and count(parameter)=1 and parameter[1][@type='E']]"
34+
[global::Java.Interop.JniMethodSignature ("compareTo", "(Ljava/lang/Enum;)I")]
2435
public unsafe int CompareTo (global::Java.Lang.Object o)
2536
{
2637
const string __id = "compareTo.(Ljava/lang/Enum;)I";
27-
IntPtr native_o = JNIEnv.ToLocalJniHandle (o);
38+
var native_o = (o?.PeerReference ?? default);
2839
try {
2940
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
3041
__args [0] = new JniArgumentValue (native_o);
3142
var __rm = _members.InstanceMethods.InvokeNonvirtualInt32Method (__id, this, __args);
3243
return __rm;
3344
} finally {
34-
JNIEnv.DeleteLocalRef (native_o);
3545
global::System.GC.KeepAlive (o);
3646
}
3747
}

tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,38 @@ namespace Java.Lang {
99
[global::Java.Interop.JavaTypeParameters (new string [] {"T"})]
1010
public partial interface IComparable : IJavaPeerable {
1111
// Metadata.xml XPath method reference: path="/api/package[@name='java.lang']/interface[@name='Comparable']/method[@name='compareTo' and count(parameter)=1 and parameter[1][@type='T']]"
12+
[global::Java.Interop.JniMethodSignature ("compareTo", "(Ljava/lang/Object;)I")]
1213
int CompareTo (global::Java.Lang.Object another);
1314

1415
}
16+
17+
[global::Java.Interop.JniTypeSignature ("java/lang/Comparable", GenerateJavaPeer=false)]
18+
internal partial class IComparableInvoker : global::Java.Lang.Object, IComparable {
19+
[global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)]
20+
[global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)]
21+
public override global::Java.Interop.JniPeerMembers JniPeerMembers {
22+
get { return _members_java_lang_Comparable; }
23+
}
24+
25+
static readonly JniPeerMembers _members_java_lang_Comparable = new JniPeerMembers ("java/lang/Comparable", typeof (IComparableInvoker));
26+
27+
public IComparableInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options)
28+
{
29+
}
30+
31+
public unsafe int CompareTo (global::Java.Lang.Object another)
32+
{
33+
const string __id = "compareTo.(Ljava/lang/Object;)I";
34+
var native_another = (another?.PeerReference ?? default);
35+
try {
36+
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
37+
__args [0] = new JniArgumentValue (native_another);
38+
var __rm = _members_java_lang_Comparable.InstanceMethods.InvokeAbstractInt32Method (__id, this, __args);
39+
return __rm;
40+
} finally {
41+
global::System.GC.KeepAlive (another);
42+
}
43+
}
44+
45+
}
1546
}

0 commit comments

Comments
 (0)