From a3cf866a1b3b31b95e5a41ec6ad61c6b5a0715f9 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Wed, 12 Oct 2016 10:32:57 -0400 Subject: [PATCH] [generator] Qualify `object.GetType()` invocations Context: https://bugzilla.xamarin.com/show_bug.cgi?id=45203 Context: https://bugzilla.xamarin.com/show_bug.cgi?id=44263#c8 (Sorry; private bugs.) The `getType()` method isn't special; any Java library could contain such a method: // Java public class Example { public int[] getType() {return null;} } (It's a wonder that we haven't hit such a thing before!) Unfortunately, should such a method (1) exist, and (2) be bound as `GetType()` instead of as a `Type` property -- in the above example, we use an `int[]` return type because if a Java method has an array return type, we won't turn it into a property -- the resulting code wouldn't compile: // error CS0019: Operator `==' cannot be applied to operands of type `int[]' and `System.Type' if (GetType () == ThresholdType) ... To fix this, *qualify* all use of the `GetType()` method so that we explicitly use `System.Object.GetType()`: if ((object) this).GetType () == ThresholdType) ... This has no performance-impact, IL-wise, as the C# compiler is able to statically determine that we want non-virtual invocation of the `System.Object.GetType()` method. No runtime cast is performed. --- tools/generator/JavaInteropCodeGenerator.cs | 2 +- .../Android.Text.SpannableString.cs | 4 +- .../expected/Android.Text.SpannableString.cs | 10 +-- .../Android.Text.SpannableStringInternal.cs | 2 +- .../Tests-Core/expected/Android.Views.View.cs | 4 +- .../Adapters/Mono.Android.projitems | 19 +++++ .../Mono.Android.projitems | 15 ++++ .../expected.ji/Arrays/Mono.Android.projitems | 15 ++++ .../Constructors/Mono.Android.projitems | 15 ++++ .../Constructors/Xamarin.Test.SomeObject.cs | 4 +- .../NestedTypes/Mono.Android.projitems | 15 ++++ .../Xamarin.Test.NotificationCompatBase.cs | 2 +- .../NonStaticFields/Mono.Android.projitems | 15 ++++ .../NormalMethods/Java.Lang.Class.cs | 16 +++++ .../NormalMethods/Java.Lang.Throwable.cs | 13 ++++ .../NormalMethods/Mono.Android.projitems | 20 ++++++ .../NormalMethods/Xamarin.Test.SomeObject.cs | 30 +++++++- .../NormalProperties/Mono.Android.projitems | 15 ++++ .../ParameterXPath/Mono.Android.projitems | 16 +++++ .../StaticFields/Mono.Android.projitems | 15 ++++ .../StaticMethods/Mono.Android.projitems | 15 ++++ .../StaticProperties/Mono.Android.projitems | 15 ++++ .../Streams/Java.IO.FilterOutputStream.cs | 2 +- .../Streams/Java.IO.InputStream.cs | 2 +- .../Streams/Java.IO.OutputStream.cs | 2 +- .../Streams/Mono.Android.projitems | 19 +++++ .../TestInterface/Mono.Android.projitems | 20 ++++++ .../Test.ME.GenericImplementation.cs | 2 +- .../Test.ME.GenericStringImplementation.cs | 2 +- .../Test.ME.TestInterfaceImplementation.cs | 2 +- .../java.lang.Enum/Mono.Android.projitems | 17 +++++ .../java.lang.Object/Mono.Android.projitems | 14 ++++ .../java.util.List/Mono.Android.projitems | 15 ++++ tools/generator/Tests/expected.targets | 72 +++++++++++++++++++ .../Adapters/Xamarin.Test.AbsSpinner.cs | 4 +- .../Xamarin.Test.GenericReturnObject.cs | 2 +- .../Constructors/Xamarin.Test.SomeObject.cs | 8 +-- .../Xamarin.Test.SomeObject.cs | 4 +- .../Xamarin.Test.SomeObject2.cs | 8 +-- .../Xamarin.Test.NotificationCompatBase.cs | 4 +- .../expected/NormalMethods/NormalMethods.xml | 17 +++++ .../expected/NormalMethods/Xamarin.Test.A.cs | 4 +- .../expected/NormalMethods/Xamarin.Test.C.cs | 2 +- .../NormalMethods/Xamarin.Test.SomeObject.cs | 53 +++++++++++--- .../expected/ParameterXPath/Xamarin.Test.A.cs | 4 +- .../Streams/Java.IO.FilterOutputStream.cs | 6 +- .../expected/Streams/Java.IO.IOException.cs | 2 +- .../expected/Streams/Java.IO.InputStream.cs | 20 +++--- .../expected/Streams/Java.IO.OutputStream.cs | 12 ++-- .../expected/Streams/Java.Lang.Throwable.cs | 2 +- .../Test.ME.GenericImplementation.cs | 6 +- .../Test.ME.GenericStringImplementation.cs | 6 +- .../Test.ME.TestInterfaceImplementation.cs | 4 +- .../generator/XamarinAndroidCodeGenerator.cs | 6 +- 54 files changed, 537 insertions(+), 83 deletions(-) create mode 100644 tools/generator/Tests/expected.ji/Adapters/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/Android.Graphics.Color/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/Arrays/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/Constructors/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/NestedTypes/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/NonStaticFields/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/NormalMethods/Java.Lang.Class.cs create mode 100644 tools/generator/Tests/expected.ji/NormalMethods/Java.Lang.Throwable.cs create mode 100644 tools/generator/Tests/expected.ji/NormalMethods/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/NormalProperties/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/ParameterXPath/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/StaticFields/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/StaticMethods/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/StaticProperties/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/Streams/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/TestInterface/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/java.lang.Enum/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/java.lang.Object/Mono.Android.projitems create mode 100644 tools/generator/Tests/expected.ji/java.util.List/Mono.Android.projitems diff --git a/tools/generator/JavaInteropCodeGenerator.cs b/tools/generator/JavaInteropCodeGenerator.cs index b3f181fab..d4bc4e918 100644 --- a/tools/generator/JavaInteropCodeGenerator.cs +++ b/tools/generator/JavaInteropCodeGenerator.cs @@ -124,7 +124,7 @@ internal override void WriteConstructorBody (Ctor ctor, StreamWriter sw, string var oldindent = indent; indent += "\t"; ctor.Parameters.WriteCallArgs (sw, indent, opt, invoker:false); - sw.WriteLine ("{0}var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (){1});", indent, ctor.Parameters.GetCallArgs (opt, invoker:false)); + sw.WriteLine ("{0}var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (){1});", indent, ctor.Parameters.GetCallArgs (opt, invoker:false)); sw.WriteLine ("{0}SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef);", indent); sw.WriteLine ("{0}_members.InstanceMethods.FinishCreateInstance (__id, this{1});", indent, ctor.Parameters.GetCallArgs (opt, invoker:false)); indent = oldindent; diff --git a/tools/generator/Tests-Core/expected.ji/Android.Text.SpannableString.cs b/tools/generator/Tests-Core/expected.ji/Android.Text.SpannableString.cs index fa6525e38..68b1fd6d5 100644 --- a/tools/generator/Tests-Core/expected.ji/Android.Text.SpannableString.cs +++ b/tools/generator/Tests-Core/expected.ji/Android.Text.SpannableString.cs @@ -44,7 +44,7 @@ public unsafe SpannableString (Java.Lang.ICharSequence source) try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (native_source); - var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), __args); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); _members.InstanceMethods.FinishCreateInstance (__id, this, __args); } finally { @@ -65,7 +65,7 @@ public unsafe SpannableString (string source) try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (native_source); - var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), __args); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); _members.InstanceMethods.FinishCreateInstance (__id, this, __args); } finally { diff --git a/tools/generator/Tests-Core/expected/Android.Text.SpannableString.cs b/tools/generator/Tests-Core/expected/Android.Text.SpannableString.cs index 1521a4378..8f660048d 100644 --- a/tools/generator/Tests-Core/expected/Android.Text.SpannableString.cs +++ b/tools/generator/Tests-Core/expected/Android.Text.SpannableString.cs @@ -38,9 +38,9 @@ public unsafe SpannableString (Java.Lang.ICharSequence source) try { JValue* __args = stackalloc JValue [1]; __args [0] = new JValue (native_source); - if (GetType () != typeof (SpannableString)) { + if (((object) this).GetType () != typeof (SpannableString)) { SetHandle ( - global::Android.Runtime.JNIEnv.StartCreateInstance (GetType (), "(Ljava/lang/CharSequence;)V", __args), + global::Android.Runtime.JNIEnv.StartCreateInstance (((object) this).GetType (), "(Ljava/lang/CharSequence;)V", __args), JniHandleOwnership.TransferLocalRef); global::Android.Runtime.JNIEnv.FinishCreateInstance (((global::Java.Lang.Object) this).Handle, "(Ljava/lang/CharSequence;)V", __args); return; @@ -68,9 +68,9 @@ public unsafe SpannableString (string source) try { JValue* __args = stackalloc JValue [1]; __args [0] = new JValue (native_source); - if (GetType () != typeof (SpannableString)) { + if (((object) this).GetType () != typeof (SpannableString)) { SetHandle ( - global::Android.Runtime.JNIEnv.StartCreateInstance (GetType (), "(Ljava/lang/CharSequence;)V", __args), + global::Android.Runtime.JNIEnv.StartCreateInstance (((object) this).GetType (), "(Ljava/lang/CharSequence;)V", __args), JniHandleOwnership.TransferLocalRef); global::Android.Runtime.JNIEnv.FinishCreateInstance (((global::Java.Lang.Object) this).Handle, "(Ljava/lang/CharSequence;)V", __args); return; @@ -117,7 +117,7 @@ public override unsafe Android.Text.SpanTypes GetSpanFlags (Java.Lang.Object wha __args [0] = new JValue (what); Android.Text.SpanTypes __ret; - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) __ret = (Android.Text.SpanTypes) JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_getSpanFlags_Ljava_lang_Object_, __args); else __ret = (Android.Text.SpanTypes) JNIEnv.CallNonvirtualIntMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "getSpanFlags", "(Ljava/lang/Object;)I"), __args); diff --git a/tools/generator/Tests-Core/expected/Android.Text.SpannableStringInternal.cs b/tools/generator/Tests-Core/expected/Android.Text.SpannableStringInternal.cs index 49770d887..f8023994c 100644 --- a/tools/generator/Tests-Core/expected/Android.Text.SpannableStringInternal.cs +++ b/tools/generator/Tests-Core/expected/Android.Text.SpannableStringInternal.cs @@ -56,7 +56,7 @@ public virtual unsafe Android.Text.SpanTypes GetSpanFlags (Java.Lang.Object p0) __args [0] = new JValue (p0); Android.Text.SpanTypes __ret; - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) __ret = (Android.Text.SpanTypes) JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_getSpanFlags_Ljava_lang_Object_, __args); else __ret = (Android.Text.SpanTypes) JNIEnv.CallNonvirtualIntMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "getSpanFlags", "(Ljava/lang/Object;)I"), __args); diff --git a/tools/generator/Tests-Core/expected/Android.Views.View.cs b/tools/generator/Tests-Core/expected/Android.Views.View.cs index 615cf2329..d8459ddb2 100644 --- a/tools/generator/Tests-Core/expected/Android.Views.View.cs +++ b/tools/generator/Tests-Core/expected/Android.Views.View.cs @@ -164,7 +164,7 @@ public virtual unsafe void SetOnClickListener (Android.Views.View.IOnClickListen JValue* __args = stackalloc JValue [1]; __args [0] = new JValue (l); - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_setOnClickListener_Landroid_view_View_OnClickListener_, __args); else JNIEnv.CallNonvirtualVoidMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "setOnClickListener", "(Landroid/view/View$OnClickListener;)V"), __args); @@ -201,7 +201,7 @@ public virtual unsafe void AddTouchables (System.Collections.Generic.IList + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/Android.Graphics.Color/Mono.Android.projitems b/tools/generator/Tests/expected.ji/Android.Graphics.Color/Mono.Android.projitems new file mode 100644 index 000000000..ef0f66313 --- /dev/null +++ b/tools/generator/Tests/expected.ji/Android.Graphics.Color/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/Arrays/Mono.Android.projitems b/tools/generator/Tests/expected.ji/Arrays/Mono.Android.projitems new file mode 100644 index 000000000..ef0f66313 --- /dev/null +++ b/tools/generator/Tests/expected.ji/Arrays/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/Constructors/Mono.Android.projitems b/tools/generator/Tests/expected.ji/Constructors/Mono.Android.projitems new file mode 100644 index 000000000..ef0f66313 --- /dev/null +++ b/tools/generator/Tests/expected.ji/Constructors/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/Constructors/Xamarin.Test.SomeObject.cs b/tools/generator/Tests/expected.ji/Constructors/Xamarin.Test.SomeObject.cs index 290a15e40..9d93bd535 100644 --- a/tools/generator/Tests/expected.ji/Constructors/Xamarin.Test.SomeObject.cs +++ b/tools/generator/Tests/expected.ji/Constructors/Xamarin.Test.SomeObject.cs @@ -41,7 +41,7 @@ public unsafe SomeObject () return; try { - var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), null); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { @@ -61,7 +61,7 @@ public unsafe SomeObject (int aint) try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (aint); - var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), __args); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); _members.InstanceMethods.FinishCreateInstance (__id, this, __args); } finally { diff --git a/tools/generator/Tests/expected.ji/NestedTypes/Mono.Android.projitems b/tools/generator/Tests/expected.ji/NestedTypes/Mono.Android.projitems new file mode 100644 index 000000000..75fe7536e --- /dev/null +++ b/tools/generator/Tests/expected.ji/NestedTypes/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs b/tools/generator/Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs index b1a420b30..5fd145a45 100644 --- a/tools/generator/Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs +++ b/tools/generator/Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs @@ -163,7 +163,7 @@ public unsafe InstanceInner (global::Xamarin.Test.NotificationCompatBase __self) try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue ((__self == null) ? IntPtr.Zero : ((global::Java.Lang.Object) __self).Handle); - var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), __args); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); _members.InstanceMethods.FinishCreateInstance (__id, this, __args); } finally { diff --git a/tools/generator/Tests/expected.ji/NonStaticFields/Mono.Android.projitems b/tools/generator/Tests/expected.ji/NonStaticFields/Mono.Android.projitems new file mode 100644 index 000000000..ef0f66313 --- /dev/null +++ b/tools/generator/Tests/expected.ji/NonStaticFields/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/NormalMethods/Java.Lang.Class.cs b/tools/generator/Tests/expected.ji/NormalMethods/Java.Lang.Class.cs new file mode 100644 index 000000000..96b1be034 --- /dev/null +++ b/tools/generator/Tests/expected.ji/NormalMethods/Java.Lang.Class.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Class']" + [global::Android.Runtime.Register ("java/lang/Class", DoNotGenerateAcw=true)] + [global::Java.Interop.JavaTypeParameters (new string [] {"T"})] + public partial class Class : global::Java.Lang.Object { + + protected Class (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) {} + + } +} diff --git a/tools/generator/Tests/expected.ji/NormalMethods/Java.Lang.Throwable.cs b/tools/generator/Tests/expected.ji/NormalMethods/Java.Lang.Throwable.cs new file mode 100644 index 000000000..da03ab54d --- /dev/null +++ b/tools/generator/Tests/expected.ji/NormalMethods/Java.Lang.Throwable.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using Android.Runtime; +using Java.Interop; + +namespace Java.Lang { + + // Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Throwable']" + [global::Android.Runtime.Register ("java/lang/Throwable", DoNotGenerateAcw=true)] + public partial class Throwable { + + } +} diff --git a/tools/generator/Tests/expected.ji/NormalMethods/Mono.Android.projitems b/tools/generator/Tests/expected.ji/NormalMethods/Mono.Android.projitems new file mode 100644 index 000000000..e763b9f8c --- /dev/null +++ b/tools/generator/Tests/expected.ji/NormalMethods/Mono.Android.projitems @@ -0,0 +1,20 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/NormalMethods/Xamarin.Test.SomeObject.cs b/tools/generator/Tests/expected.ji/NormalMethods/Xamarin.Test.SomeObject.cs index e6ff80ef2..4d57e4f54 100644 --- a/tools/generator/Tests/expected.ji/NormalMethods/Xamarin.Test.SomeObject.cs +++ b/tools/generator/Tests/expected.ji/NormalMethods/Xamarin.Test.SomeObject.cs @@ -43,13 +43,41 @@ public unsafe SomeObject (global::Java.Lang.Class c) try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue ((c == null) ? IntPtr.Zero : ((global::Java.Lang.Object) c).Handle); - var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), __args); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); _members.InstanceMethods.FinishCreateInstance (__id, this, __args); } finally { } } + static Delegate cb_getType; +#pragma warning disable 0169 + static Delegate GetGetTypeHandler () + { + if (cb_getType == null) + cb_getType = JNINativeWrapper.CreateDelegate ((Func) n_GetType); + return cb_getType; + } + + static IntPtr n_GetType (IntPtr jnienv, IntPtr native__this) + { + global::Xamarin.Test.SomeObject __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.NewArray (__this.GetType ()); + } +#pragma warning restore 0169 + + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getType' and count(parameter)=0]" + [Register ("getType", "()[I", "GetGetTypeHandler")] + public virtual unsafe int[] GetType () + { + const string __id = "getType.()[I"; + try { + var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null); + return (int[]) JNIEnv.GetArray (__rm.Handle, JniHandleOwnership.TransferLocalRef, typeof (int)); + } finally { + } + } + static Delegate cb_handle_Ljava_lang_Object_Ljava_lang_Throwable_; #pragma warning disable 0169 static Delegate GetHandle_Ljava_lang_Object_Ljava_lang_Throwable_Handler () diff --git a/tools/generator/Tests/expected.ji/NormalProperties/Mono.Android.projitems b/tools/generator/Tests/expected.ji/NormalProperties/Mono.Android.projitems new file mode 100644 index 000000000..ef0f66313 --- /dev/null +++ b/tools/generator/Tests/expected.ji/NormalProperties/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/ParameterXPath/Mono.Android.projitems b/tools/generator/Tests/expected.ji/ParameterXPath/Mono.Android.projitems new file mode 100644 index 000000000..57fc0427c --- /dev/null +++ b/tools/generator/Tests/expected.ji/ParameterXPath/Mono.Android.projitems @@ -0,0 +1,16 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/StaticFields/Mono.Android.projitems b/tools/generator/Tests/expected.ji/StaticFields/Mono.Android.projitems new file mode 100644 index 000000000..ef0f66313 --- /dev/null +++ b/tools/generator/Tests/expected.ji/StaticFields/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/StaticMethods/Mono.Android.projitems b/tools/generator/Tests/expected.ji/StaticMethods/Mono.Android.projitems new file mode 100644 index 000000000..ef0f66313 --- /dev/null +++ b/tools/generator/Tests/expected.ji/StaticMethods/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/StaticProperties/Mono.Android.projitems b/tools/generator/Tests/expected.ji/StaticProperties/Mono.Android.projitems new file mode 100644 index 000000000..ef0f66313 --- /dev/null +++ b/tools/generator/Tests/expected.ji/StaticProperties/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/Streams/Java.IO.FilterOutputStream.cs b/tools/generator/Tests/expected.ji/Streams/Java.IO.FilterOutputStream.cs index 378ca57fa..8bf191b6c 100644 --- a/tools/generator/Tests/expected.ji/Streams/Java.IO.FilterOutputStream.cs +++ b/tools/generator/Tests/expected.ji/Streams/Java.IO.FilterOutputStream.cs @@ -44,7 +44,7 @@ public unsafe FilterOutputStream (global::System.IO.Stream @out) try { JniArgumentValue* __args = stackalloc JniArgumentValue [1]; __args [0] = new JniArgumentValue (native__out); - var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), __args); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args); SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); _members.InstanceMethods.FinishCreateInstance (__id, this, __args); } finally { diff --git a/tools/generator/Tests/expected.ji/Streams/Java.IO.InputStream.cs b/tools/generator/Tests/expected.ji/Streams/Java.IO.InputStream.cs index b2c8a7afa..197b3f0f8 100644 --- a/tools/generator/Tests/expected.ji/Streams/Java.IO.InputStream.cs +++ b/tools/generator/Tests/expected.ji/Streams/Java.IO.InputStream.cs @@ -41,7 +41,7 @@ public unsafe InputStream () return; try { - var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), null); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { diff --git a/tools/generator/Tests/expected.ji/Streams/Java.IO.OutputStream.cs b/tools/generator/Tests/expected.ji/Streams/Java.IO.OutputStream.cs index cf72ee7fc..f536bd179 100644 --- a/tools/generator/Tests/expected.ji/Streams/Java.IO.OutputStream.cs +++ b/tools/generator/Tests/expected.ji/Streams/Java.IO.OutputStream.cs @@ -41,7 +41,7 @@ public unsafe OutputStream () return; try { - var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), null); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { diff --git a/tools/generator/Tests/expected.ji/Streams/Mono.Android.projitems b/tools/generator/Tests/expected.ji/Streams/Mono.Android.projitems new file mode 100644 index 000000000..97b1a98d3 --- /dev/null +++ b/tools/generator/Tests/expected.ji/Streams/Mono.Android.projitems @@ -0,0 +1,19 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/TestInterface/Mono.Android.projitems b/tools/generator/Tests/expected.ji/TestInterface/Mono.Android.projitems new file mode 100644 index 000000000..2e5733412 --- /dev/null +++ b/tools/generator/Tests/expected.ji/TestInterface/Mono.Android.projitems @@ -0,0 +1,20 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/TestInterface/Test.ME.GenericImplementation.cs b/tools/generator/Tests/expected.ji/TestInterface/Test.ME.GenericImplementation.cs index 82a622eb4..afece635d 100644 --- a/tools/generator/Tests/expected.ji/TestInterface/Test.ME.GenericImplementation.cs +++ b/tools/generator/Tests/expected.ji/TestInterface/Test.ME.GenericImplementation.cs @@ -41,7 +41,7 @@ public unsafe GenericImplementation () return; try { - var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), null); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { diff --git a/tools/generator/Tests/expected.ji/TestInterface/Test.ME.GenericStringImplementation.cs b/tools/generator/Tests/expected.ji/TestInterface/Test.ME.GenericStringImplementation.cs index 66a46f153..578dc75f7 100644 --- a/tools/generator/Tests/expected.ji/TestInterface/Test.ME.GenericStringImplementation.cs +++ b/tools/generator/Tests/expected.ji/TestInterface/Test.ME.GenericStringImplementation.cs @@ -41,7 +41,7 @@ public unsafe GenericStringImplementation () return; try { - var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), null); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { diff --git a/tools/generator/Tests/expected.ji/TestInterface/Test.ME.TestInterfaceImplementation.cs b/tools/generator/Tests/expected.ji/TestInterface/Test.ME.TestInterfaceImplementation.cs index 352b31368..38ad4966f 100644 --- a/tools/generator/Tests/expected.ji/TestInterface/Test.ME.TestInterfaceImplementation.cs +++ b/tools/generator/Tests/expected.ji/TestInterface/Test.ME.TestInterfaceImplementation.cs @@ -63,7 +63,7 @@ public unsafe TestInterfaceImplementation () return; try { - var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), null); + var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null); SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef); _members.InstanceMethods.FinishCreateInstance (__id, this, null); } finally { diff --git a/tools/generator/Tests/expected.ji/java.lang.Enum/Mono.Android.projitems b/tools/generator/Tests/expected.ji/java.lang.Enum/Mono.Android.projitems new file mode 100644 index 000000000..31e134216 --- /dev/null +++ b/tools/generator/Tests/expected.ji/java.lang.Enum/Mono.Android.projitems @@ -0,0 +1,17 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/java.lang.Object/Mono.Android.projitems b/tools/generator/Tests/expected.ji/java.lang.Object/Mono.Android.projitems new file mode 100644 index 000000000..f0e062a49 --- /dev/null +++ b/tools/generator/Tests/expected.ji/java.lang.Object/Mono.Android.projitems @@ -0,0 +1,14 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.ji/java.util.List/Mono.Android.projitems b/tools/generator/Tests/expected.ji/java.util.List/Mono.Android.projitems new file mode 100644 index 000000000..ef0f66313 --- /dev/null +++ b/tools/generator/Tests/expected.ji/java.util.List/Mono.Android.projitems @@ -0,0 +1,15 @@ + + + + $(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4 + + + + + + + + + + + \ No newline at end of file diff --git a/tools/generator/Tests/expected.targets b/tools/generator/Tests/expected.targets index 49bfb0963..a0c7b21b3 100644 --- a/tools/generator/Tests/expected.targets +++ b/tools/generator/Tests/expected.targets @@ -6,6 +6,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -33,6 +36,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -48,6 +54,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -63,6 +72,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -78,6 +90,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -93,6 +108,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -105,12 +123,21 @@ PreserveNewest + + PreserveNewest + PreserveNewest PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -132,6 +159,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -150,6 +180,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -165,6 +198,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -180,6 +216,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -195,6 +234,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -207,6 +249,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -219,6 +264,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -234,6 +285,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -270,6 +324,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -282,6 +339,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -294,6 +354,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -384,6 +447,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -429,12 +495,18 @@ PreserveNewest + + PreserveNewest + PreserveNewest PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/tools/generator/Tests/expected/Adapters/Xamarin.Test.AbsSpinner.cs b/tools/generator/Tests/expected/Adapters/Xamarin.Test.AbsSpinner.cs index 1727fdeba..713b92a6d 100644 --- a/tools/generator/Tests/expected/Adapters/Xamarin.Test.AbsSpinner.cs +++ b/tools/generator/Tests/expected/Adapters/Xamarin.Test.AbsSpinner.cs @@ -68,7 +68,7 @@ static void n_SetAdapter_Lxamarin_test_SpinnerAdapter_ (IntPtr jnienv, IntPtr na id_getAdapter = JNIEnv.GetMethodID (class_ref, "getAdapter", "()Lxamarin/test/SpinnerAdapter;"); try { - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) return global::Java.Lang.Object.GetObject (JNIEnv.CallObjectMethod (((global::Java.Lang.Object) this).Handle, id_getAdapter), JniHandleOwnership.TransferLocalRef); else return global::Java.Lang.Object.GetObject (JNIEnv.CallNonvirtualObjectMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "getAdapter", "()Lxamarin/test/SpinnerAdapter;")), JniHandleOwnership.TransferLocalRef); @@ -84,7 +84,7 @@ static void n_SetAdapter_Lxamarin_test_SpinnerAdapter_ (IntPtr jnienv, IntPtr na JValue* __args = stackalloc JValue [1]; __args [0] = new JValue (value); - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_setAdapter_Lxamarin_test_SpinnerAdapter_, __args); else JNIEnv.CallNonvirtualVoidMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "setAdapter", "(Lxamarin/test/SpinnerAdapter;)V"), __args); diff --git a/tools/generator/Tests/expected/Adapters/Xamarin.Test.GenericReturnObject.cs b/tools/generator/Tests/expected/Adapters/Xamarin.Test.GenericReturnObject.cs index f331764d8..920a44ca3 100644 --- a/tools/generator/Tests/expected/Adapters/Xamarin.Test.GenericReturnObject.cs +++ b/tools/generator/Tests/expected/Adapters/Xamarin.Test.GenericReturnObject.cs @@ -50,7 +50,7 @@ static IntPtr n_GenericReturn (IntPtr jnienv, IntPtr native__this) id_GenericReturn = JNIEnv.GetMethodID (class_ref, "GenericReturn", "()Lxamarin/test/AdapterView;"); try { - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) return global::Java.Lang.Object.GetObject (JNIEnv.CallObjectMethod (((global::Java.Lang.Object) this).Handle, id_GenericReturn), JniHandleOwnership.TransferLocalRef); else return global::Java.Lang.Object.GetObject (JNIEnv.CallNonvirtualObjectMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "GenericReturn", "()Lxamarin/test/AdapterView;")), JniHandleOwnership.TransferLocalRef); diff --git a/tools/generator/Tests/expected/Constructors/Xamarin.Test.SomeObject.cs b/tools/generator/Tests/expected/Constructors/Xamarin.Test.SomeObject.cs index 7d5844ba7..37d6e0550 100644 --- a/tools/generator/Tests/expected/Constructors/Xamarin.Test.SomeObject.cs +++ b/tools/generator/Tests/expected/Constructors/Xamarin.Test.SomeObject.cs @@ -35,9 +35,9 @@ public unsafe SomeObject () return; try { - if (GetType () != typeof (SomeObject)) { + if (((object) this).GetType () != typeof (SomeObject)) { SetHandle ( - global::Android.Runtime.JNIEnv.StartCreateInstance (GetType (), "()V"), + global::Android.Runtime.JNIEnv.StartCreateInstance (((object) this).GetType (), "()V"), JniHandleOwnership.TransferLocalRef); global::Android.Runtime.JNIEnv.FinishCreateInstance (((global::Java.Lang.Object) this).Handle, "()V"); return; @@ -65,9 +65,9 @@ public unsafe SomeObject (int aint) try { JValue* __args = stackalloc JValue [1]; __args [0] = new JValue (aint); - if (GetType () != typeof (SomeObject)) { + if (((object) this).GetType () != typeof (SomeObject)) { SetHandle ( - global::Android.Runtime.JNIEnv.StartCreateInstance (GetType (), "(I)V", __args), + global::Android.Runtime.JNIEnv.StartCreateInstance (((object) this).GetType (), "(I)V", __args), JniHandleOwnership.TransferLocalRef); global::Android.Runtime.JNIEnv.FinishCreateInstance (((global::Java.Lang.Object) this).Handle, "(I)V", __args); return; diff --git a/tools/generator/Tests/expected/EnumerationFixup/Xamarin.Test.SomeObject.cs b/tools/generator/Tests/expected/EnumerationFixup/Xamarin.Test.SomeObject.cs index 3f626b475..533b5098e 100644 --- a/tools/generator/Tests/expected/EnumerationFixup/Xamarin.Test.SomeObject.cs +++ b/tools/generator/Tests/expected/EnumerationFixup/Xamarin.Test.SomeObject.cs @@ -68,7 +68,7 @@ static void n_SetSomeObjectProperty_I (IntPtr jnienv, IntPtr native__this, int n id_getSomeObjectProperty = JNIEnv.GetMethodID (class_ref, "getSomeObjectProperty", "()I"); try { - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) return (global::Xamarin.Test.SomeValues) JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_getSomeObjectProperty); else return (global::Xamarin.Test.SomeValues) JNIEnv.CallNonvirtualIntMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "getSomeObjectProperty", "()I")); @@ -84,7 +84,7 @@ static void n_SetSomeObjectProperty_I (IntPtr jnienv, IntPtr native__this, int n JValue* __args = stackalloc JValue [1]; __args [0] = new JValue ((int) value); - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_setSomeObjectProperty_I, __args); else JNIEnv.CallNonvirtualVoidMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "setSomeObjectProperty", "(I)V"), __args); diff --git a/tools/generator/Tests/expected/EnumerationFixup/Xamarin.Test.SomeObject2.cs b/tools/generator/Tests/expected/EnumerationFixup/Xamarin.Test.SomeObject2.cs index 5fad73c23..eb10fd820 100644 --- a/tools/generator/Tests/expected/EnumerationFixup/Xamarin.Test.SomeObject2.cs +++ b/tools/generator/Tests/expected/EnumerationFixup/Xamarin.Test.SomeObject2.cs @@ -68,7 +68,7 @@ static void n_SetSomeObjectProperty_I (IntPtr jnienv, IntPtr native__this, int n id_getSomeObjectProperty = JNIEnv.GetMethodID (class_ref, "getSomeObjectProperty", "()I"); try { - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) return (global::Xamarin.Test.SomeValues) JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_getSomeObjectProperty); else return (global::Xamarin.Test.SomeValues) JNIEnv.CallNonvirtualIntMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "getSomeObjectProperty", "()I")); @@ -84,7 +84,7 @@ static void n_SetSomeObjectProperty_I (IntPtr jnienv, IntPtr native__this, int n JValue* __args = stackalloc JValue [1]; __args [0] = new JValue ((int) value); - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_setSomeObjectProperty_I, __args); else JNIEnv.CallNonvirtualVoidMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "setSomeObjectProperty", "(I)V"), __args); @@ -119,7 +119,7 @@ static IntPtr n_GetSomeObjectPropertyArray (IntPtr jnienv, IntPtr native__this) id_getSomeObjectPropertyArray = JNIEnv.GetMethodID (class_ref, "getSomeObjectPropertyArray", "()[I"); try { - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) return (global::Xamarin.Test.SomeValues[]) JNIEnv.GetArray (JNIEnv.CallObjectMethod (((global::Java.Lang.Object) this).Handle, id_getSomeObjectPropertyArray), JniHandleOwnership.TransferLocalRef, typeof (global::Xamarin.Test.SomeValues)); else return (global::Xamarin.Test.SomeValues[]) JNIEnv.GetArray (JNIEnv.CallNonvirtualObjectMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "getSomeObjectPropertyArray", "()[I")), JniHandleOwnership.TransferLocalRef, typeof (global::Xamarin.Test.SomeValues)); @@ -158,7 +158,7 @@ public virtual unsafe void SetSomeObjectPropertyArray ([global::Android.Runtime. JValue* __args = stackalloc JValue [1]; __args [0] = new JValue (native_newvalue); - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_setSomeObjectPropertyArray_arrayI, __args); else JNIEnv.CallNonvirtualVoidMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "setSomeObjectPropertyArray", "([I)V"), __args); diff --git a/tools/generator/Tests/expected/NestedTypes/Xamarin.Test.NotificationCompatBase.cs b/tools/generator/Tests/expected/NestedTypes/Xamarin.Test.NotificationCompatBase.cs index 0f9f64a48..a55517e06 100644 --- a/tools/generator/Tests/expected/NestedTypes/Xamarin.Test.NotificationCompatBase.cs +++ b/tools/generator/Tests/expected/NestedTypes/Xamarin.Test.NotificationCompatBase.cs @@ -143,9 +143,9 @@ public unsafe InstanceInner (global::Xamarin.Test.NotificationCompatBase __self) try { JValue* __args = stackalloc JValue [1]; __args [0] = new JValue (__self); - if (GetType () != typeof (InstanceInner)) { + if (((object) this).GetType () != typeof (InstanceInner)) { SetHandle ( - global::Android.Runtime.JNIEnv.StartCreateInstance (GetType (), "(L" + global::Android.Runtime.JNIEnv.GetJniName (GetType ().DeclaringType) + ";)V", __args), + global::Android.Runtime.JNIEnv.StartCreateInstance (((object) this).GetType (), "(L" + global::Android.Runtime.JNIEnv.GetJniName (GetType ().DeclaringType) + ";)V", __args), JniHandleOwnership.TransferLocalRef); global::Android.Runtime.JNIEnv.FinishCreateInstance (((global::Java.Lang.Object) this).Handle, "(L" + global::Android.Runtime.JNIEnv.GetJniName (GetType ().DeclaringType) + ";)V", __args); return; diff --git a/tools/generator/Tests/expected/NormalMethods/NormalMethods.xml b/tools/generator/Tests/expected/NormalMethods/NormalMethods.xml index 2f13e4bfc..673acc976 100644 --- a/tools/generator/Tests/expected/NormalMethods/NormalMethods.xml +++ b/tools/generator/Tests/expected/NormalMethods/NormalMethods.xml @@ -15,11 +15,28 @@ + + + diff --git a/tools/generator/Tests/expected/NormalMethods/Xamarin.Test.A.cs b/tools/generator/Tests/expected/NormalMethods/Xamarin.Test.A.cs index a87d08613..6fa525920 100644 --- a/tools/generator/Tests/expected/NormalMethods/Xamarin.Test.A.cs +++ b/tools/generator/Tests/expected/NormalMethods/Xamarin.Test.A.cs @@ -57,7 +57,7 @@ static IntPtr n_SetCustomDimension_I (IntPtr jnienv, IntPtr native__this, int in JValue* __args = stackalloc JValue [1]; __args [0] = new JValue (index); - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) return (Java.Lang.Object) global::Java.Lang.Object.GetObject (JNIEnv.CallObjectMethod (((global::Java.Lang.Object) this).Handle, id_setCustomDimension_I, __args), JniHandleOwnership.TransferLocalRef); else return (Java.Lang.Object) global::Java.Lang.Object.GetObject (JNIEnv.CallNonvirtualObjectMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "setCustomDimension", "(I)Lxamarin/test/A$B;"), __args), JniHandleOwnership.TransferLocalRef); @@ -109,7 +109,7 @@ public virtual unsafe int GetHandle () id_getHandle = JNIEnv.GetMethodID (class_ref, "getHandle", "()I"); try { - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) return JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_getHandle); else return JNIEnv.CallNonvirtualIntMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "getHandle", "()I")); diff --git a/tools/generator/Tests/expected/NormalMethods/Xamarin.Test.C.cs b/tools/generator/Tests/expected/NormalMethods/Xamarin.Test.C.cs index cab83ed43..25babee02 100644 --- a/tools/generator/Tests/expected/NormalMethods/Xamarin.Test.C.cs +++ b/tools/generator/Tests/expected/NormalMethods/Xamarin.Test.C.cs @@ -53,7 +53,7 @@ static IntPtr n_SetCustomDimension_I (IntPtr jnienv, IntPtr native__this, int in JValue* __args = stackalloc JValue [1]; __args [0] = new JValue (index); - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) return (Java.Lang.Object) global::Java.Lang.Object.GetObject (JNIEnv.CallObjectMethod (((global::Java.Lang.Object) this).Handle, id_setCustomDimension_I, __args), JniHandleOwnership.TransferLocalRef); else return (Java.Lang.Object) global::Java.Lang.Object.GetObject (JNIEnv.CallNonvirtualObjectMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "setCustomDimension", "(I)Lxamarin/test/C;"), __args), JniHandleOwnership.TransferLocalRef); diff --git a/tools/generator/Tests/expected/NormalMethods/Xamarin.Test.SomeObject.cs b/tools/generator/Tests/expected/NormalMethods/Xamarin.Test.SomeObject.cs index f0e9aff07..39983a318 100644 --- a/tools/generator/Tests/expected/NormalMethods/Xamarin.Test.SomeObject.cs +++ b/tools/generator/Tests/expected/NormalMethods/Xamarin.Test.SomeObject.cs @@ -37,9 +37,9 @@ public unsafe SomeObject (global::Java.Lang.Class c) try { JValue* __args = stackalloc JValue [1]; __args [0] = new JValue (c); - if (GetType () != typeof (SomeObject)) { + if (((object) this).GetType () != typeof (SomeObject)) { SetHandle ( - global::Android.Runtime.JNIEnv.StartCreateInstance (GetType (), "(Ljava/lang/Class;)V", __args), + global::Android.Runtime.JNIEnv.StartCreateInstance (((object) this).GetType (), "(Ljava/lang/Class;)V", __args), JniHandleOwnership.TransferLocalRef); global::Android.Runtime.JNIEnv.FinishCreateInstance (((global::Java.Lang.Object) this).Handle, "(Ljava/lang/Class;)V", __args); return; @@ -55,6 +55,39 @@ public unsafe SomeObject (global::Java.Lang.Class c) } } + static Delegate cb_getType; +#pragma warning disable 0169 + static Delegate GetGetTypeHandler () + { + if (cb_getType == null) + cb_getType = JNINativeWrapper.CreateDelegate ((Func) n_GetType); + return cb_getType; + } + + static IntPtr n_GetType (IntPtr jnienv, IntPtr native__this) + { + global::Xamarin.Test.SomeObject __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.NewArray (__this.GetType ()); + } +#pragma warning restore 0169 + + static IntPtr id_getType; + // Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getType' and count(parameter)=0]" + [Register ("getType", "()[I", "GetGetTypeHandler")] + public virtual unsafe int[] GetType () + { + if (id_getType == IntPtr.Zero) + id_getType = JNIEnv.GetMethodID (class_ref, "getType", "()[I"); + try { + + if (((object) this).GetType () == ThresholdType) + return (int[]) JNIEnv.GetArray (JNIEnv.CallObjectMethod (((global::Java.Lang.Object) this).Handle, id_getType), JniHandleOwnership.TransferLocalRef, typeof (int)); + else + return (int[]) JNIEnv.GetArray (JNIEnv.CallNonvirtualObjectMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "getType", "()[I")), JniHandleOwnership.TransferLocalRef, typeof (int)); + } finally { + } + } + static Delegate cb_handle_Ljava_lang_Object_Ljava_lang_Throwable_; #pragma warning disable 0169 static Delegate GetHandle_Ljava_lang_Object_Ljava_lang_Throwable_Handler () @@ -87,7 +120,7 @@ static int n_Handle_Ljava_lang_Object_Ljava_lang_Throwable_ (IntPtr jnienv, IntP __args [1] = new JValue (t); int __ret; - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) __ret = JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_handle_Ljava_lang_Object_Ljava_lang_Throwable_, __args); else __ret = JNIEnv.CallNonvirtualIntMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "handle", "(Ljava/lang/Object;Ljava/lang/Throwable;)I"), __args); @@ -121,7 +154,7 @@ public virtual unsafe int IntegerMethod () id_IntegerMethod = JNIEnv.GetMethodID (class_ref, "IntegerMethod", "()I"); try { - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) return JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_IntegerMethod); else return JNIEnv.CallNonvirtualIntMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "IntegerMethod", "()I")); @@ -154,7 +187,7 @@ public virtual unsafe void VoidMethod () id_VoidMethod = JNIEnv.GetMethodID (class_ref, "VoidMethod", "()V"); try { - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_VoidMethod); else JNIEnv.CallNonvirtualVoidMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "VoidMethod", "()V")); @@ -187,7 +220,7 @@ public virtual unsafe string StringMethod () id_StringMethod = JNIEnv.GetMethodID (class_ref, "StringMethod", "()Ljava/lang/String;"); try { - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) return JNIEnv.GetString (JNIEnv.CallObjectMethod (((global::Java.Lang.Object) this).Handle, id_StringMethod), JniHandleOwnership.TransferLocalRef); else return JNIEnv.GetString (JNIEnv.CallNonvirtualObjectMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "StringMethod", "()Ljava/lang/String;")), JniHandleOwnership.TransferLocalRef); @@ -220,7 +253,7 @@ static IntPtr n_ObjectMethod (IntPtr jnienv, IntPtr native__this) id_ObjectMethod = JNIEnv.GetMethodID (class_ref, "ObjectMethod", "()Ljava/lang/Object;"); try { - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) return global::Java.Lang.Object.GetObject (JNIEnv.CallObjectMethod (((global::Java.Lang.Object) this).Handle, id_ObjectMethod), JniHandleOwnership.TransferLocalRef); else return global::Java.Lang.Object.GetObject (JNIEnv.CallNonvirtualObjectMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "ObjectMethod", "()Ljava/lang/Object;")), JniHandleOwnership.TransferLocalRef); @@ -260,7 +293,7 @@ public virtual unsafe void VoidMethodWithParams (string astring, int anint, glob __args [1] = new JValue (anint); __args [2] = new JValue (anObject); - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_, __args); else JNIEnv.CallNonvirtualVoidMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "VoidMethodWithParams", "(Ljava/lang/String;ILjava/lang/Object;)V"), __args); @@ -295,7 +328,7 @@ public virtual unsafe int ObsoleteMethod () id_ObsoleteMethod = JNIEnv.GetMethodID (class_ref, "ObsoleteMethod", "()I"); try { - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) return JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_ObsoleteMethod); else return JNIEnv.CallNonvirtualIntMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "ObsoleteMethod", "()I")); @@ -332,7 +365,7 @@ public virtual unsafe void ArrayListTest (global::System.Collections.Generic.ILi JValue* __args = stackalloc JValue [1]; __args [0] = new JValue (native_p0); - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_ArrayListTest_Ljava_util_ArrayList_, __args); else JNIEnv.CallNonvirtualVoidMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "ArrayListTest", "(Ljava/util/ArrayList;)V"), __args); diff --git a/tools/generator/Tests/expected/ParameterXPath/Xamarin.Test.A.cs b/tools/generator/Tests/expected/ParameterXPath/Xamarin.Test.A.cs index 67b724d3f..999325733 100644 --- a/tools/generator/Tests/expected/ParameterXPath/Xamarin.Test.A.cs +++ b/tools/generator/Tests/expected/ParameterXPath/Xamarin.Test.A.cs @@ -55,7 +55,7 @@ public virtual unsafe void SetA (global::Java.Lang.Object adapter) JValue* __args = stackalloc JValue [1]; __args [0] = new JValue (native_adapter); - if (GetType () == ThresholdType) + if (((object) this).GetType () == ThresholdType) JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_setA_Ljava_lang_Object_, __args); else JNIEnv.CallNonvirtualVoidMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "setA", "(Ljava/lang/Object;)V"), __args); @@ -93,7 +93,7 @@ public virtual unsafe void ListTest (global::System.Collections.Generic.IList