{"action":"created","issue":{"url":"https://api.github.com/repos/xamarin/java.interop/issues/287","repository_url":"https://api.github.com/repos/xamarin/java.interop","labels_url":"https://api.github.com/repos/xamarin/java.interop/issues/287/labels{/name}","comments_url":"https://api.github.com/repos/xamarin/java.interop/issues/287/comments","events_url":"https://api.github.com/repos/xamarin/java.interop/issues/287/events","html_url":"https://github.com/xamarin/java.interop/pull/287","id":311900114,"number":287,"title":"[jnimarshalmethod-gen] Further improve the marshaling","user":{"login":"radekdoulik","id":4147484,"avatar_url":"https://avatars0.githubusercontent.com/u/4147484?v=4","gravatar_id":"","url":"https://api.github.com/users/radekdoulik","html_url":"https://github.com/radekdoulik","followers_url":"https://api.github.com/users/radekdoulik/followers","following_url":"https://api.github.com/users/radekdoulik/following{/other_user}","gists_url":"https://api.github.com/users/radekdoulik/gists{/gist_id}","starred_url":"https://api.github.com/users/radekdoulik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radekdoulik/subscriptions","organizations_url":"https://api.github.com/users/radekdoulik/orgs","repos_url":"https://api.github.com/users/radekdoulik/repos","events_url":"https://api.github.com/users/radekdoulik/events{/privacy}","received_events_url":"https://api.github.com/users/radekdoulik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-04-06T09:03:47Z","updated_at":"2018-04-06T11:16:27Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/xamarin/java.interop/pulls/287","html_url":"https://github.com/xamarin/java.interop/pull/287","diff_url":"https://github.com/xamarin/java.interop/pull/287.diff","patch_url":"https://github.com/xamarin/java.interop/pull/287.patch"},"body":"Improve the marshaling methods registration by removing/replacing\r\ncalls to `System.Type::GetType (string)` and\r\n`System.Delegate::CreateDelegate (...)` in the registration methods.\r\n\r\nAlso added new option to inject debug output into the registration\r\nmethod.\r\n\r\nWe do that to get better registration methods, compared to the original\r\nmethods we produce by our code, which uses Linq.Expressions.\r\nhttps://github.com/xamarin/java.interop/blob/master/tools/jnimarshalmethod-gen/App.cs#L242-L257.\r\n\r\nThis should improve the registration time and also reduces the\r\nregistration method size. In case of activity overriding OnCreate the\r\ncode size shrinks from 68 to 48. The registration method now looks\r\nlike this:\r\n```\r\n[JniAddNativeMethodRegistration]\r\npublic static void __RegisterNativeMembers (JniNativeMethodRegistrationArguments args)\r\n{\r\n\targs.AddRegistrations (new JniNativeMethodRegistration[] {\r\n\t\tnew JniNativeMethodRegistration (\"n_onCreate\", \"(Landroid/os/Bundle;)V\", new Action<IntPtr, IntPtr, IntPtr> (MainActivity.__<$>_jni_marshal_methods.n_onCreate_Landroid_os_Bundle_))\r\n\t});\r\n}\r\n```\r\n```\r\n.method public static void  __RegisterNativeMembers([Java.Interop]Java.Interop.JniNativeMethodRegistrationArguments args) cil managed\r\n{\r\n  .custom instance void [Java.Interop]Java.Interop.JniAddNativeMethodRegistrationAttribute::.ctor() = ( 01 00 00 00 )\r\n  // Code size       48 (0x30)\r\n  .maxstack  8\r\n  IL_0000:  ldarga.s   args\r\n  IL_0002:  ldc.i4.1\r\n  IL_0003:  newarr     [Java.Interop]Java.Interop.JniNativeMethodRegistration\r\n  IL_0008:  dup\r\n  IL_0009:  ldc.i4.0\r\n  IL_000a:  ldstr      \"n_onCreate\"\r\n  IL_000f:  ldstr      \"(Landroid/os/Bundle;)V\"\r\n  IL_0014:  ldnull\r\n  IL_0015:  ldftn      void xatemplateaot.MainActivity/'__<$>_jni_marshal_methods'::n_onCreate_Landroid_os_Bundle_(native int,\r\n                                                                                                                   native int,\r\n                                                                                                                   native int)\r\n  IL_001b:  newobj     instance void [mscorlib]System.Action`3<native int,native int,native int>::.ctor(object,\r\n                                                                                                        native int)\r\n  IL_0020:  newobj     instance void [Java.Interop]Java.Interop.JniNativeMethodRegistration::.ctor(string,\r\n                                                                                                   string,\r\n                                                                                                   [mscorlib_3]System.Delegate)\r\n  IL_0025:  stelem     [Java.Interop]Java.Interop.JniNativeMethodRegistration\r\n  IL_002a:  call       instance void [Java.Interop]Java.Interop.JniNativeMethodRegistrationArguments::AddRegistrations([mscorlib]System.Collections.Generic.IEnumerable`1<[Java.Interop]Java.Interop.JniNativeMethodRegistration>)\r\n  IL_002f:  ret\r\n} // end of method '__<$>_jni_marshal_methods'::__RegisterNativeMembers\r\n```\r\n\r\nOriginal generated method:\r\n```\r\n[JniAddNativeMethodRegistration]\r\npublic static void __RegisterNativeMembers (JniNativeMethodRegistrationArguments args)\r\n{\r\n\tType type = Type.GetType (\"xatemplateaot.MainActivity\");\r\n\targs.AddRegistrations (new JniNativeMethodRegistration[] {\r\n\t\tnew JniNativeMethodRegistration (\"n_onCreate\", \"(Landroid/os/Bundle;)V\", Delegate.CreateDelegate (typeof(Action<IntPtr, IntPtr, IntPtr>), type, \"n_onCreate_Landroid_os_Bundle_\"))\r\n\t});\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/xamarin/java.interop/issues/comments/379223651","html_url":"https://github.com/xamarin/java.interop/pull/287#issuecomment-379223651","issue_url":"https://api.github.com/repos/xamarin/java.interop/issues/287","id":379223651,"user":{"login":"radekdoulik","id":4147484,"avatar_url":"https://avatars0.githubusercontent.com/u/4147484?v=4","gravatar_id":"","url":"https://api.github.com/users/radekdoulik","html_url":"https://github.com/radekdoulik","followers_url":"https://api.github.com/users/radekdoulik/followers","following_url":"https://api.github.com/users/radekdoulik/following{/other_user}","gists_url":"https://api.github.com/users/radekdoulik/gists{/gist_id}","starred_url":"https://api.github.com/users/radekdoulik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radekdoulik/subscriptions","organizations_url":"https://api.github.com/users/radekdoulik/orgs","repos_url":"https://api.github.com/users/radekdoulik/repos","events_url":"https://api.github.com/users/radekdoulik/events{/privacy}","received_events_url":"https://api.github.com/users/radekdoulik/received_events","type":"User","site_admin":false},"created_at":"2018-04-06T11:16:27Z","updated_at":"2018-04-06T11:16:27Z","author_association":"CONTRIBUTOR","body":"The build scripts should not use it. It is there to help with the tool development itself, to make sure the code is really used. It shouldn't be used in a normal build."}}
{"actor":{"display_login":"radekdoulik"}}