{"action":"created","comment":{"url":"https://api.github.com/repos/xamarin/xamarin-macios/pulls/comments/95715348","pull_request_review_id":16279807,"id":95715348,"diff_hunk":"@@ -1117,6 +1118,226 @@ static string FindProtocolInterface (Type type, MemberInfo pi)\n \t\treturn \"I\" + type.Name;\n \t}\n \n+\t// TODO: Alex\n+\tpublic static BindAsAttribute GetBindAsAttribute (ICustomAttributeProvider cu) => GetAttribute<BindAsAttribute> (cu) ?? GetAttribute<BindAsAttribute> ((cu as MethodInfo)?.ReturnParameter);\n+\tpublic static bool HasBindAsAttribute (ICustomAttributeProvider cu) => (GetAttribute<BindAsAttribute> (cu) ?? GetAttribute<BindAsAttribute> ((cu as MethodInfo)?.ReturnParameter)) != null;\n+\tstatic bool IsSetter (MethodInfo mi) => mi.IsSpecialName && mi.Name.StartsWith (\"set_\", StringComparison.Ordinal);\n+\n+\tstring GetToBindAsWrapper (MemberInformation minfo = null, ParameterInfo pi = null)\n+\t{\n+\t\tBindAsAttribute attrib = null;\n+\t\tstring className = null;\n+\t\tstring temp = null;\n+\n+\t\tif (pi == null) {\n+\t\t\tattrib = GetBindAsAttribute (minfo.mi);\n+\t\t\tvar property = minfo.mi as PropertyInfo;\n+\t\t\tvar method = minfo.mi as MethodInfo;\n+\t\t\tclassName = method?.ReturnType?.Name ?? property?.PropertyType?.Name;\n+\t\t} else {\n+\t\t\tattrib = GetBindAsAttribute (pi);\n+\t\t\tclassName = pi.ParameterType.Name;\n+\t\t}\n+\n+\t\tvar retType = Nullable.GetUnderlyingType (attrib.Type) ?? attrib.Type;\n+\t\tvar isNullable = attrib.IsNullable;\n+\t\tvar isValueType = retType.IsValueType;\n+\n+\t\tif (isNullable || !isValueType)\n+\t\t\ttemp = string.Format (\"{0} == null ? null : \", pi != null ? pi.Name.GetSafeParamName () : \"value\");\n+\n+\t\tif (className == \"NSNumber\")\n+\t\t\ttemp = string.Format (\"new NSNumber ({1}{0});\", isNullable ? \".Value\" : string.Empty, pi != null ? pi.Name.GetSafeParamName () : \"value\");\n+\n+\t\telse if (className == \"NSValue\") {\n+\t\t\tswitch (retType.Name) {\n+\t\t\tcase \"CATransform3D\":\n+\t\t\t\ttemp = string.Format (\"NSValue.FromCATransform3D ({1}{0});\", isNullable ? \".Value\" : string.Empty, pi != null ? pi.Name.GetSafeParamName () : \"value\");\n+\t\t\tbreak;","path":"src/generator.cs","position":47,"original_position":47,"commit_id":"d13c593133861c03ad3defd58a250995db14b52a","original_commit_id":"d13c593133861c03ad3defd58a250995db14b52a","user":{"login":"dalexsoto","id":204671,"avatar_url":"https://avatars.githubusercontent.com/u/204671?v=3","gravatar_id":"","url":"https://api.github.com/users/dalexsoto","html_url":"https://github.com/dalexsoto","followers_url":"https://api.github.com/users/dalexsoto/followers","following_url":"https://api.github.com/users/dalexsoto/following{/other_user}","gists_url":"https://api.github.com/users/dalexsoto/gists{/gist_id}","starred_url":"https://api.github.com/users/dalexsoto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dalexsoto/subscriptions","organizations_url":"https://api.github.com/users/dalexsoto/orgs","repos_url":"https://api.github.com/users/dalexsoto/repos","events_url":"https://api.github.com/users/dalexsoto/events{/privacy}","received_events_url":"https://api.github.com/users/dalexsoto/received_events","type":"User","site_admin":false},"body":"Oh yeah my bad, thanks!","created_at":"2017-01-12T02:28:15Z","updated_at":"2017-01-12T02:28:15Z","html_url":"https://github.com/xamarin/xamarin-macios/pull/1476#discussion_r95715348","pull_request_url":"https://api.github.com/repos/xamarin/xamarin-macios/pulls/1476","_links":{"self":{"href":"https://api.github.com/repos/xamarin/xamarin-macios/pulls/comments/95715348"},"html":{"href":"https://github.com/xamarin/xamarin-macios/pull/1476#discussion_r95715348"},"pull_request":{"href":"https://api.github.com/repos/xamarin/xamarin-macios/pulls/1476"}}},"pull_request":{"url":"https://api.github.com/repos/xamarin/xamarin-macios/pulls/1476","id":101174145,"html_url":"https://github.com/xamarin/xamarin-macios/pull/1476","diff_url":"https://github.com/xamarin/xamarin-macios/pull/1476.diff","patch_url":"https://github.com/xamarin/xamarin-macios/pull/1476.patch","issue_url":"https://api.github.com/repos/xamarin/xamarin-macios/issues/1476","number":1476,"state":"open","locked":false,"title":"[generator][WIP] Add BindAs support","user":{"login":"dalexsoto","id":204671,"avatar_url":"https://avatars.githubusercontent.com/u/204671?v=3","gravatar_id":"","url":"https://api.github.com/users/dalexsoto","html_url":"https://github.com/dalexsoto","followers_url":"https://api.github.com/users/dalexsoto/followers","following_url":"https://api.github.com/users/dalexsoto/following{/other_user}","gists_url":"https://api.github.com/users/dalexsoto/gists{/gist_id}","starred_url":"https://api.github.com/users/dalexsoto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dalexsoto/subscriptions","organizations_url":"https://api.github.com/users/dalexsoto/orgs","repos_url":"https://api.github.com/users/dalexsoto/repos","events_url":"https://api.github.com/users/dalexsoto/events{/privacy}","received_events_url":"https://api.github.com/users/dalexsoto/received_events","type":"User","site_admin":false},"body":"The intent of BindAs attribute is to have a binding definition as\r\n\r\n\t[return: BindAs (typeof (bool?))]\r\n\t[Export (\"boolMethod:\")]\r\n\tNSNumber BoolMethod (int arg1);\r\n\r\nand our generator outputs\r\n\r\n\t[Export (\"boolMethod:\")]\r\n\tpublic virtual global::System.Nullable<bool> BoolMethod (int arg1) { ...  }\r\n\r\nSo we internally do the NSNumber <-> bool conversion, this also\r\napplies to parameters, properties and methods.\r\n\r\nTODO:\r\n- [x] Properties, Methods and Parameters support\r\n- [x] NSNumber support\r\n- [x] NSValue support\r\n- [ ] Smart enum/enum support\r\n- [x] Tests\r\n","created_at":"2017-01-12T00:17:23Z","updated_at":"2017-01-12T02:28:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cd2b8f90295aae04bb8bd5c3709ff08dc318b328","assignee":{"login":"dalexsoto","id":204671,"avatar_url":"https://avatars.githubusercontent.com/u/204671?v=3","gravatar_id":"","url":"https://api.github.com/users/dalexsoto","html_url":"https://github.com/dalexsoto","followers_url":"https://api.github.com/users/dalexsoto/followers","following_url":"https://api.github.com/users/dalexsoto/following{/other_user}","gists_url":"https://api.github.com/users/dalexsoto/gists{/gist_id}","starred_url":"https://api.github.com/users/dalexsoto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dalexsoto/subscriptions","organizations_url":"https://api.github.com/users/dalexsoto/orgs","repos_url":"https://api.github.com/users/dalexsoto/repos","events_url":"https://api.github.com/users/dalexsoto/events{/privacy}","received_events_url":"https://api.github.com/users/dalexsoto/received_events","type":"User","site_admin":false},"assignees":[{"login":"dalexsoto","id":204671,"avatar_url":"https://avatars.githubusercontent.com/u/204671?v=3","gravatar_id":"","url":"https://api.github.com/users/dalexsoto","html_url":"https://github.com/dalexsoto","followers_url":"https://api.github.com/users/dalexsoto/followers","following_url":"https://api.github.com/users/dalexsoto/following{/other_user}","gists_url":"https://api.github.com/users/dalexsoto/gists{/gist_id}","starred_url":"https://api.github.com/users/dalexsoto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dalexsoto/subscriptions","organizations_url":"https://api.github.com/users/dalexsoto/orgs","repos_url":"https://api.github.com/users/dalexsoto/repos","events_url":"https://api.github.com/users/dalexsoto/events{/privacy}","received_events_url":"https://api.github.com/users/dalexsoto/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/xamarin/xamarin-macios/pulls/1476/commits","review_comments_url":"https://api.github.com/repos/xamarin/xamarin-macios/pulls/1476/comments","review_comment_url":"https://api.github.com/repos/xamarin/xamarin-macios/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xamarin/xamarin-macios/issues/1476/comments","statuses_url":"https://api.github.com/repos/xamarin/xamarin-macios/statuses/d13c593133861c03ad3defd58a250995db14b52a","head":{"label":"dalexsoto:bindas","ref":"bindas","sha":"d13c593133861c03ad3defd58a250995db14b52a","user":{"login":"dalexsoto","id":204671,"avatar_url":"https://avatars.githubusercontent.com/u/204671?v=3","gravatar_id":"","url":"https://api.github.com/users/dalexsoto","html_url":"https://github.com/dalexsoto","followers_url":"https://api.github.com/users/dalexsoto/followers","following_url":"https://api.github.com/users/dalexsoto/following{/other_user}","gists_url":"https://api.github.com/users/dalexsoto/gists{/gist_id}","starred_url":"https://api.github.com/users/dalexsoto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dalexsoto/subscriptions","organizations_url":"https://api.github.com/users/dalexsoto/orgs","repos_url":"https://api.github.com/users/dalexsoto/repos","events_url":"https://api.github.com/users/dalexsoto/events{/privacy}","received_events_url":"https://api.github.com/users/dalexsoto/received_events","type":"User","site_admin":false},"repo":{"id":57973046,"name":"xamarin-macios","full_name":"dalexsoto/xamarin-macios","owner":{"login":"dalexsoto","id":204671,"avatar_url":"https://avatars.githubusercontent.com/u/204671?v=3","gravatar_id":"","url":"https://api.github.com/users/dalexsoto","html_url":"https://github.com/dalexsoto","followers_url":"https://api.github.com/users/dalexsoto/followers","following_url":"https://api.github.com/users/dalexsoto/following{/other_user}","gists_url":"https://api.github.com/users/dalexsoto/gists{/gist_id}","starred_url":"https://api.github.com/users/dalexsoto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dalexsoto/subscriptions","organizations_url":"https://api.github.com/users/dalexsoto/orgs","repos_url":"https://api.github.com/users/dalexsoto/repos","events_url":"https://api.github.com/users/dalexsoto/events{/privacy}","received_events_url":"https://api.github.com/users/dalexsoto/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dalexsoto/xamarin-macios","description":"Bridges the worlds of .NET with the native APIs of Mac, iOS, tvOS, and watchOS.","fork":true,"url":"https://api.github.com/repos/dalexsoto/xamarin-macios","forks_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/forks","keys_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/teams","hooks_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/hooks","issue_events_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/issues/events{/number}","events_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/events","assignees_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/assignees{/user}","branches_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/branches{/branch}","tags_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/tags","blobs_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/git/refs{/sha}","trees_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/statuses/{sha}","languages_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/languages","stargazers_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/stargazers","contributors_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/contributors","subscribers_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/subscribers","subscription_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/subscription","commits_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/commits{/sha}","git_commits_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/git/commits{/sha}","comments_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/comments{/number}","issue_comment_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/issues/comments{/number}","contents_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/contents/{+path}","compare_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/merges","archive_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/downloads","issues_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/issues{/number}","pulls_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/pulls{/number}","milestones_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/milestones{/number}","notifications_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/labels{/name}","releases_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/releases{/id}","deployments_url":"https://api.github.com/repos/dalexsoto/xamarin-macios/deployments","created_at":"2016-05-03T13:53:35Z","updated_at":"2016-05-03T13:53:42Z","pushed_at":"2017-01-12T00:44:18Z","git_url":"git://github.com/dalexsoto/xamarin-macios.git","ssh_url":"git@github.com:dalexsoto/xamarin-macios.git","clone_url":"https://github.com/dalexsoto/xamarin-macios.git","svn_url":"https://github.com/dalexsoto/xamarin-macios","homepage":null,"size":42428,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"xamarin:master","ref":"master","sha":"ffe142d0b5af5f526b6889d7b899e0d3a82fab6d","user":{"login":"xamarin","id":790012,"avatar_url":"https://avatars.githubusercontent.com/u/790012?v=3","gravatar_id":"","url":"https://api.github.com/users/xamarin","html_url":"https://github.com/xamarin","followers_url":"https://api.github.com/users/xamarin/followers","following_url":"https://api.github.com/users/xamarin/following{/other_user}","gists_url":"https://api.github.com/users/xamarin/gists{/gist_id}","starred_url":"https://api.github.com/users/xamarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xamarin/subscriptions","organizations_url":"https://api.github.com/users/xamarin/orgs","repos_url":"https://api.github.com/users/xamarin/repos","events_url":"https://api.github.com/users/xamarin/events{/privacy}","received_events_url":"https://api.github.com/users/xamarin/received_events","type":"Organization","site_admin":false},"repo":{"id":56710511,"name":"xamarin-macios","full_name":"xamarin/xamarin-macios","owner":{"login":"xamarin","id":790012,"avatar_url":"https://avatars.githubusercontent.com/u/790012?v=3","gravatar_id":"","url":"https://api.github.com/users/xamarin","html_url":"https://github.com/xamarin","followers_url":"https://api.github.com/users/xamarin/followers","following_url":"https://api.github.com/users/xamarin/following{/other_user}","gists_url":"https://api.github.com/users/xamarin/gists{/gist_id}","starred_url":"https://api.github.com/users/xamarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xamarin/subscriptions","organizations_url":"https://api.github.com/users/xamarin/orgs","repos_url":"https://api.github.com/users/xamarin/repos","events_url":"https://api.github.com/users/xamarin/events{/privacy}","received_events_url":"https://api.github.com/users/xamarin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xamarin/xamarin-macios","description":"Bridges the worlds of .NET with the native APIs of Mac, iOS, tvOS, and watchOS.","fork":false,"url":"https://api.github.com/repos/xamarin/xamarin-macios","forks_url":"https://api.github.com/repos/xamarin/xamarin-macios/forks","keys_url":"https://api.github.com/repos/xamarin/xamarin-macios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xamarin/xamarin-macios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xamarin/xamarin-macios/teams","hooks_url":"https://api.github.com/repos/xamarin/xamarin-macios/hooks","issue_events_url":"https://api.github.com/repos/xamarin/xamarin-macios/issues/events{/number}","events_url":"https://api.github.com/repos/xamarin/xamarin-macios/events","assignees_url":"https://api.github.com/repos/xamarin/xamarin-macios/assignees{/user}","branches_url":"https://api.github.com/repos/xamarin/xamarin-macios/branches{/branch}","tags_url":"https://api.github.com/repos/xamarin/xamarin-macios/tags","blobs_url":"https://api.github.com/repos/xamarin/xamarin-macios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xamarin/xamarin-macios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xamarin/xamarin-macios/git/refs{/sha}","trees_url":"https://api.github.com/repos/xamarin/xamarin-macios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xamarin/xamarin-macios/statuses/{sha}","languages_url":"https://api.github.com/repos/xamarin/xamarin-macios/languages","stargazers_url":"https://api.github.com/repos/xamarin/xamarin-macios/stargazers","contributors_url":"https://api.github.com/repos/xamarin/xamarin-macios/contributors","subscribers_url":"https://api.github.com/repos/xamarin/xamarin-macios/subscribers","subscription_url":"https://api.github.com/repos/xamarin/xamarin-macios/subscription","commits_url":"https://api.github.com/repos/xamarin/xamarin-macios/commits{/sha}","git_commits_url":"https://api.github.com/repos/xamarin/xamarin-macios/git/commits{/sha}","comments_url":"https://api.github.com/repos/xamarin/xamarin-macios/comments{/number}","issue_comment_url":"https://api.github.com/repos/xamarin/xamarin-macios/issues/comments{/number}","contents_url":"https://api.github.com/repos/xamarin/xamarin-macios/contents/{+path}","compare_url":"https://api.github.com/repos/xamarin/xamarin-macios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xamarin/xamarin-macios/merges","archive_url":"https://api.github.com/repos/xamarin/xamarin-macios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xamarin/xamarin-macios/downloads","issues_url":"https://api.github.com/repos/xamarin/xamarin-macios/issues{/number}","pulls_url":"https://api.github.com/repos/xamarin/xamarin-macios/pulls{/number}","milestones_url":"https://api.github.com/repos/xamarin/xamarin-macios/milestones{/number}","notifications_url":"https://api.github.com/repos/xamarin/xamarin-macios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xamarin/xamarin-macios/labels{/name}","releases_url":"https://api.github.com/repos/xamarin/xamarin-macios/releases{/id}","deployments_url":"https://api.github.com/repos/xamarin/xamarin-macios/deployments","created_at":"2016-04-20T18:24:26Z","updated_at":"2017-01-08T23:19:04Z","pushed_at":"2017-01-12T02:25:57Z","git_url":"git://github.com/xamarin/xamarin-macios.git","ssh_url":"git@github.com:xamarin/xamarin-macios.git","clone_url":"https://github.com/xamarin/xamarin-macios.git","svn_url":"https://github.com/xamarin/xamarin-macios","homepage":null,"size":42935,"stargazers_count":678,"watchers_count":678,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":131,"mirror_url":null,"open_issues_count":14,"forks":131,"open_issues":14,"watchers":678,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xamarin/xamarin-macios/pulls/1476"},"html":{"href":"https://github.com/xamarin/xamarin-macios/pull/1476"},"issue":{"href":"https://api.github.com/repos/xamarin/xamarin-macios/issues/1476"},"comments":{"href":"https://api.github.com/repos/xamarin/xamarin-macios/issues/1476/comments"},"review_comments":{"href":"https://api.github.com/repos/xamarin/xamarin-macios/pulls/1476/comments"},"review_comment":{"href":"https://api.github.com/repos/xamarin/xamarin-macios/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xamarin/xamarin-macios/pulls/1476/commits"},"statuses":{"href":"https://api.github.com/repos/xamarin/xamarin-macios/statuses/d13c593133861c03ad3defd58a250995db14b52a"}}}}
{"actor":{"display_login":"dalexsoto"}}