public void GenericConstructors()
        {
            string xml = @"<api>
		  <package name='XXX'>
		    <class abstract='true' deprecated='not deprecated' final='false' name='GenericConstructors' static='false' visibility='public' jni-signature='Landroid/app/GenericConstructors' extends='java.lang.Object' extends-generic-aware='java.lang.Object'>
		      <constructor deprecated='not deprecated' final='false' name='GenericConstructors' static='false' visibility='public' jni-signature='(LTTE;)V'>
		        <typeParameters>
		          <typeParameter name='E' interfaceBounds='' jni-interfaceBounds='' />
		        </typeParameters>
		        <parameter name = 'e' type='E' jni-type='TE;'>
		        </parameter>
		      </constructor>
		    </class>
		  </package>
		</api>"        ;

            var xapi = JavaApiTestHelper.GetLoadedApi();

            JavaXmlApiImporter.ParseString(xml, xapi);

            var results = xapi.ResolveCollection();

            var t = xapi.Packages ["XXX"].Types.First(_ => _.Name == "GenericConstructors") as JavaClassModel;
            var m = t.Constructors.FirstOrDefault();

            Assert.IsNotNull(m.TypeParameters, "constructor not found");
        }
        public void AncestralOverrides()
        {
            string xml = @"<api>
  <package name='XXX'>
    <class abstract='true' deprecated='not deprecated' extends='android.app.ExpandableListActivity' extends-generic-aware='android.app.ExpandableListActivity' final='false' name='SherlockExpandableListActivity' static='false' visibility='public' jni-signature='Landroid/app/ExpandableListActivity;'>
      <method abstract='false' deprecated='not deprecated' final='false' name='addContentView' native='false' return='void' static='false' synchronized='false' visibility='public' jni-signature='(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V'>
        <parameter name = 'view' type='android.view.View' jni-type='Landroid/view/View;'>
        </parameter>
        <parameter name = 'params' type='android.view.ViewGroup.LayoutParams' jni-type='Landroid/view/ViewGroup$LayoutParams;'>
        </parameter>
      </method>
    </class>
  </package>
</api>";

            var xapi = JavaApiTestHelper.GetLoadedApi();

            JavaXmlApiImporter.ParseString(xml, xapi);

            xapi.ResolveCollection();

            var t = xapi.Packages ["XXX"].Types.First(_ => _.Name == "SherlockExpandableListActivity");
            var m = t.Methods.First(_ => _.Name == "addContentView");

            Assert.IsNotNull(m.BaseMethod, "base method not found");
        }
예제 #3
0
        public void IntentServiceHack()
        {
            // https://github.com/xamarin/java.interop/issues/717
            var api = JavaApiTestHelper.GetLoadedApi();

            // Create "mono.android.app" package
            var mono_android_app = api.AddPackage("mono.android.app", "mono/android/app");

            // Remove "android.app.IntentService" type
            var android_app    = api.Packages["android.app"];
            var intent_service = android_app.Types.Single(t => t.Name == "IntentService");

            android_app.Types.Remove(intent_service);
            api.RemoveType(intent_service);

            // Create new "mono.android.app.IntentService" type
            var new_intent_service = JavaApiTestHelper.CreateClass(mono_android_app, "IntentService");

            api.AddType(new_intent_service);

            api.ResolveCollection();

            // Ensure we can resolve the type by either name
            Assert.AreSame(new_intent_service, api.FindType("mono.android.app.IntentService"));
            Assert.AreSame(new_intent_service, api.FindType("android.app.IntentService"));
        }
예제 #4
0
        public void InheritedGenericTypeParameters()
        {
            // Ensure we can resolve generic type parameters from parent types:
            // public class MyClass<T>
            // {
            //     public class MyNestedClass<U>
            //     {
            //       public void DoT (T value) { }
            //       public void DoU (U value) { }
            //     }
            // }
            var xml = @"
<api api-source='class-parse'>
   <package name='example' jni-name='example'>
      <class abstract='false' deprecated='not deprecated' jni-extends='Ljava/lang/Object;' extends='java.lang.Object' extends-generic-aware='java.lang.Object' final='false' name='MyClass' jni-signature='Lexample/MyClass;' source-file-name='MyClass.java' static='false' visibility='public'>
         <typeParameters>
            <typeParameter name='T' jni-classBound='Ljava/lang/Object;' classBound='java.lang.Object' interfaceBounds='' jni-interfaceBounds='' />
         </typeParameters>
         <constructor deprecated='not deprecated' final='false' name='MyClass' static='false' visibility='public' bridge='false' synthetic='false' jni-signature='()V' />
      </class>
      <class abstract='false' deprecated='not deprecated' jni-extends='Ljava/lang/Object;' extends='java.lang.Object' extends-generic-aware='java.lang.Object' final='false' name='MyClass.MyNestedClass' jni-signature='Lexample/MyClass$MyNestedClass;' source-file-name='MyClass.java' static='false' visibility='public'>
         <typeParameters>
            <typeParameter name='U' jni-classBound='Ljava/lang/Object;' classBound='java.lang.Object' interfaceBounds='' jni-interfaceBounds='' />
         </typeParameters>
         <constructor deprecated='not deprecated' final='false' name='MyClass.MyNestedClass' static='false' visibility='public' bridge='false' synthetic='false' jni-signature='(Lexample/MyClass;)V' />
         <method abstract='false' deprecated='not deprecated' final='false' name='DoT' native='false' return='void' jni-return='V' static='false' synchronized='false' visibility='public' bridge='false' synthetic='false' jni-signature='(Ljava/lang/Object;)V'>
            <parameter name='p0' type='T' jni-type='TT;' />
         </method>
         <method abstract='false' deprecated='not deprecated' final='false' name='DoU' native='false' return='void' jni-return='V' static='false' synchronized='false' visibility='public' bridge='false' synthetic='false' jni-signature='(Ljava/lang/Object;)V'>
            <parameter name='p0' type='U' jni-type='TU;' />
         </method>
      </class>
   </package>
</api>";

            var xapi = JavaApiTestHelper.GetLoadedApi();

            JavaXmlApiImporter.ParseString(xml, xapi);

            var results = xapi.ResolveCollection();

            var t = xapi.Packages ["example"].Types.First(_ => _.Name == "MyClass").NestedTypes.First(_ => _.Name == "MyNestedClass") as JavaClassModel;

            Assert.AreEqual(2, t.Methods.Count);

            Assert.IsNotNull(t.Methods.SingleOrDefault(m => m.Name == "DoT"), "Method with generic T not found");
            Assert.IsNotNull(t.Methods.SingleOrDefault(m => m.Name == "DoU"), "Method with generic U not found");
        }
 public void SetupFixture()
 {
     api = JavaApiTestHelper.GetLoadedApi();
 }
 public void SetupFixture()
 {
     api = JavaApiTestHelper.GetLoadedApi();
     api.ResolveCollection();
 }