{"action":"created","comment":{"url":"https://api.github.com/repos/CommBank/humbug/pulls/comments/29824001","id":29824001,"diff_hunk":"@@ -0,0 +1,147 @@\n+//   Copyright 2015 Commonwealth Bank of Australia\n+//\n+//   Licensed under the Apache License, Version 2.0 (the \"License\");\n+//   you may not use this file except in compliance with the License.\n+//   You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+//   Unless required by applicable law or agreed to in writing, software\n+//   distributed under the License is distributed on an \"AS IS\" BASIS,\n+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+//   See the License for the specific language governing permissions and\n+//   limitations under the License.\n+\n+package au.com.cba.omnia.humbug.macros\n+\n+import language.experimental.macros\n+\n+import reflect.macros.Context\n+\n+import scala.reflect.macros.Context\n+\n+import org.scalacheck.Arbitrary\n+\n+import com.twitter.scrooge._\n+\n+import au.com.cba.omnia.humbug.HumbugThriftStruct\n+\n+/**\n+  * This macro creates Arbitrary instances for Thrift structs\n+  */\n+object ArbitraryThriftMacro {\n+\n+  val ProductField = \"\"\"_(\\d+)\"\"\".r\n+\n+  /** Gets all the fields of a Thrift struct sorted in order of definition.*/\n+  def fields[A <: ThriftStruct: c.WeakTypeTag](c: Context): List[(c.universe.MethodSymbol, String)] =\n+    fieldsUnsafe(c)(c.universe.weakTypeOf[A])\n+\n+  /** Same as fields but for any type where the type is assumed to be ThriftStruct.*/\n+  def fieldsUnsafe(c: Context)(typ: c.universe.Type): List[(c.universe.MethodSymbol, String)] = {","path":"test/src/main/scala/au/com/cba/omnia/humbug/macros/ArbitraryThriftMacro.scala","position":41,"original_position":41,"commit_id":"5427fc856d2e845fc5a838cc26fd8816bc20aa46","original_commit_id":"5427fc856d2e845fc5a838cc26fd8816bc20aa46","user":{"login":"stephanh","id":376868,"avatar_url":"https://avatars.githubusercontent.com/u/376868?v=3","gravatar_id":"","url":"https://api.github.com/users/stephanh","html_url":"https://github.com/stephanh","followers_url":"https://api.github.com/users/stephanh/followers","following_url":"https://api.github.com/users/stephanh/following{/other_user}","gists_url":"https://api.github.com/users/stephanh/gists{/gist_id}","starred_url":"https://api.github.com/users/stephanh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephanh/subscriptions","organizations_url":"https://api.github.com/users/stephanh/orgs","repos_url":"https://api.github.com/users/stephanh/repos","events_url":"https://api.github.com/users/stephanh/events{/privacy}","received_events_url":"https://api.github.com/users/stephanh/received_events","type":"User","site_admin":false},"body":"Why not merge this into fields? Since fieldsUnsafe isn't called directly?","created_at":"2015-05-07T04:37:05Z","updated_at":"2015-05-07T04:37:05Z","html_url":"https://github.com/CommBank/humbug/pull/19#discussion_r29824001","pull_request_url":"https://api.github.com/repos/CommBank/humbug/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/CommBank/humbug/pulls/comments/29824001"},"html":{"href":"https://github.com/CommBank/humbug/pull/19#discussion_r29824001"},"pull_request":{"href":"https://api.github.com/repos/CommBank/humbug/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/CommBank/humbug/pulls/19","id":34788459,"html_url":"https://github.com/CommBank/humbug/pull/19","diff_url":"https://github.com/CommBank/humbug/pull/19.diff","patch_url":"https://github.com/CommBank/humbug/pull/19.patch","issue_url":"https://api.github.com/repos/CommBank/humbug/issues/19","number":19,"state":"open","locked":false,"title":"Arbitrary thrift","user":{"login":"kfish","id":38847,"avatar_url":"https://avatars.githubusercontent.com/u/38847?v=3","gravatar_id":"","url":"https://api.github.com/users/kfish","html_url":"https://github.com/kfish","followers_url":"https://api.github.com/users/kfish/followers","following_url":"https://api.github.com/users/kfish/following{/other_user}","gists_url":"https://api.github.com/users/kfish/gists{/gist_id}","starred_url":"https://api.github.com/users/kfish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kfish/subscriptions","organizations_url":"https://api.github.com/users/kfish/orgs","repos_url":"https://api.github.com/users/kfish/repos","events_url":"https://api.github.com/users/kfish/events{/privacy}","received_events_url":"https://api.github.com/users/kfish/received_events","type":"User","site_admin":false},"body":"This branch implements a macro to generate arbitrary instances for thrift structs, as per:\r\n\r\nhttps://github.com/CommBank/ebenezer/issues/54\r\n\r\nIt is currently implemented only for scala-2.10. There is an issue with generation of fresh names in scala-2.10 (resolved in 2.11) such that we eventually want to move the test project to use 2.11. However there is currently a separate issue #18 which causes a 2.11 build of test to fail.\r\n\r\nOpen questions:\r\n\r\n * Do we want to support both 2.10 and 2.11 (after #18)\r\n\r\nClosed questions:\r\n\r\n * Do we need extra API that imports implicit defs, or should we expect client code to do:\r\n\r\n```scala\r\nimplicit def CustomerHumbugArbitrary: Arbitrary[CustomerHumbug] = thriftArbitrary[CustomerHumbug]\r\n```\r\n\r\n => yes we need API support, implemented in 5427fc8\r\n","created_at":"2015-05-06T04:42:14Z","updated_at":"2015-05-07T04:37:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b30beafedcbddfdc7b48bcd3287dd55fa6865cb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CommBank/humbug/pulls/19/commits","review_comments_url":"https://api.github.com/repos/CommBank/humbug/pulls/19/comments","review_comment_url":"https://api.github.com/repos/CommBank/humbug/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CommBank/humbug/issues/19/comments","statuses_url":"https://api.github.com/repos/CommBank/humbug/statuses/5427fc856d2e845fc5a838cc26fd8816bc20aa46","head":{"label":"CommBank:arbitrary-thrift","ref":"arbitrary-thrift","sha":"5427fc856d2e845fc5a838cc26fd8816bc20aa46","user":{"login":"CommBank","id":4240076,"avatar_url":"https://avatars.githubusercontent.com/u/4240076?v=3","gravatar_id":"","url":"https://api.github.com/users/CommBank","html_url":"https://github.com/CommBank","followers_url":"https://api.github.com/users/CommBank/followers","following_url":"https://api.github.com/users/CommBank/following{/other_user}","gists_url":"https://api.github.com/users/CommBank/gists{/gist_id}","starred_url":"https://api.github.com/users/CommBank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CommBank/subscriptions","organizations_url":"https://api.github.com/users/CommBank/orgs","repos_url":"https://api.github.com/users/CommBank/repos","events_url":"https://api.github.com/users/CommBank/events{/privacy}","received_events_url":"https://api.github.com/users/CommBank/received_events","type":"Organization","site_admin":false},"repo":{"id":19438966,"name":"humbug","full_name":"CommBank/humbug","owner":{"login":"CommBank","id":4240076,"avatar_url":"https://avatars.githubusercontent.com/u/4240076?v=3","gravatar_id":"","url":"https://api.github.com/users/CommBank","html_url":"https://github.com/CommBank","followers_url":"https://api.github.com/users/CommBank/followers","following_url":"https://api.github.com/users/CommBank/following{/other_user}","gists_url":"https://api.github.com/users/CommBank/gists{/gist_id}","starred_url":"https://api.github.com/users/CommBank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CommBank/subscriptions","organizations_url":"https://api.github.com/users/CommBank/orgs","repos_url":"https://api.github.com/users/CommBank/repos","events_url":"https://api.github.com/users/CommBank/events{/privacy}","received_events_url":"https://api.github.com/users/CommBank/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CommBank/humbug","description":"Humbug is a very simple scrooge replacement for Thrift structs with more than 254 fields","fork":false,"url":"https://api.github.com/repos/CommBank/humbug","forks_url":"https://api.github.com/repos/CommBank/humbug/forks","keys_url":"https://api.github.com/repos/CommBank/humbug/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CommBank/humbug/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CommBank/humbug/teams","hooks_url":"https://api.github.com/repos/CommBank/humbug/hooks","issue_events_url":"https://api.github.com/repos/CommBank/humbug/issues/events{/number}","events_url":"https://api.github.com/repos/CommBank/humbug/events","assignees_url":"https://api.github.com/repos/CommBank/humbug/assignees{/user}","branches_url":"https://api.github.com/repos/CommBank/humbug/branches{/branch}","tags_url":"https://api.github.com/repos/CommBank/humbug/tags","blobs_url":"https://api.github.com/repos/CommBank/humbug/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CommBank/humbug/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CommBank/humbug/git/refs{/sha}","trees_url":"https://api.github.com/repos/CommBank/humbug/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CommBank/humbug/statuses/{sha}","languages_url":"https://api.github.com/repos/CommBank/humbug/languages","stargazers_url":"https://api.github.com/repos/CommBank/humbug/stargazers","contributors_url":"https://api.github.com/repos/CommBank/humbug/contributors","subscribers_url":"https://api.github.com/repos/CommBank/humbug/subscribers","subscription_url":"https://api.github.com/repos/CommBank/humbug/subscription","commits_url":"https://api.github.com/repos/CommBank/humbug/commits{/sha}","git_commits_url":"https://api.github.com/repos/CommBank/humbug/git/commits{/sha}","comments_url":"https://api.github.com/repos/CommBank/humbug/comments{/number}","issue_comment_url":"https://api.github.com/repos/CommBank/humbug/issues/comments{/number}","contents_url":"https://api.github.com/repos/CommBank/humbug/contents/{+path}","compare_url":"https://api.github.com/repos/CommBank/humbug/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CommBank/humbug/merges","archive_url":"https://api.github.com/repos/CommBank/humbug/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CommBank/humbug/downloads","issues_url":"https://api.github.com/repos/CommBank/humbug/issues{/number}","pulls_url":"https://api.github.com/repos/CommBank/humbug/pulls{/number}","milestones_url":"https://api.github.com/repos/CommBank/humbug/milestones{/number}","notifications_url":"https://api.github.com/repos/CommBank/humbug/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CommBank/humbug/labels{/name}","releases_url":"https://api.github.com/repos/CommBank/humbug/releases{/id}","created_at":"2014-05-04T23:54:10Z","updated_at":"2015-05-04T07:05:36Z","pushed_at":"2015-05-07T03:25:14Z","git_url":"git://github.com/CommBank/humbug.git","ssh_url":"git@github.com:CommBank/humbug.git","clone_url":"https://github.com/CommBank/humbug.git","svn_url":"https://github.com/CommBank/humbug","homepage":"https://commbank.github.io/humbug","size":2394,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"CommBank:master","ref":"master","sha":"a82bbcfdb5886be558640cc013965b58fd78961a","user":{"login":"CommBank","id":4240076,"avatar_url":"https://avatars.githubusercontent.com/u/4240076?v=3","gravatar_id":"","url":"https://api.github.com/users/CommBank","html_url":"https://github.com/CommBank","followers_url":"https://api.github.com/users/CommBank/followers","following_url":"https://api.github.com/users/CommBank/following{/other_user}","gists_url":"https://api.github.com/users/CommBank/gists{/gist_id}","starred_url":"https://api.github.com/users/CommBank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CommBank/subscriptions","organizations_url":"https://api.github.com/users/CommBank/orgs","repos_url":"https://api.github.com/users/CommBank/repos","events_url":"https://api.github.com/users/CommBank/events{/privacy}","received_events_url":"https://api.github.com/users/CommBank/received_events","type":"Organization","site_admin":false},"repo":{"id":19438966,"name":"humbug","full_name":"CommBank/humbug","owner":{"login":"CommBank","id":4240076,"avatar_url":"https://avatars.githubusercontent.com/u/4240076?v=3","gravatar_id":"","url":"https://api.github.com/users/CommBank","html_url":"https://github.com/CommBank","followers_url":"https://api.github.com/users/CommBank/followers","following_url":"https://api.github.com/users/CommBank/following{/other_user}","gists_url":"https://api.github.com/users/CommBank/gists{/gist_id}","starred_url":"https://api.github.com/users/CommBank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CommBank/subscriptions","organizations_url":"https://api.github.com/users/CommBank/orgs","repos_url":"https://api.github.com/users/CommBank/repos","events_url":"https://api.github.com/users/CommBank/events{/privacy}","received_events_url":"https://api.github.com/users/CommBank/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CommBank/humbug","description":"Humbug is a very simple scrooge replacement for Thrift structs with more than 254 fields","fork":false,"url":"https://api.github.com/repos/CommBank/humbug","forks_url":"https://api.github.com/repos/CommBank/humbug/forks","keys_url":"https://api.github.com/repos/CommBank/humbug/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CommBank/humbug/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CommBank/humbug/teams","hooks_url":"https://api.github.com/repos/CommBank/humbug/hooks","issue_events_url":"https://api.github.com/repos/CommBank/humbug/issues/events{/number}","events_url":"https://api.github.com/repos/CommBank/humbug/events","assignees_url":"https://api.github.com/repos/CommBank/humbug/assignees{/user}","branches_url":"https://api.github.com/repos/CommBank/humbug/branches{/branch}","tags_url":"https://api.github.com/repos/CommBank/humbug/tags","blobs_url":"https://api.github.com/repos/CommBank/humbug/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CommBank/humbug/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CommBank/humbug/git/refs{/sha}","trees_url":"https://api.github.com/repos/CommBank/humbug/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CommBank/humbug/statuses/{sha}","languages_url":"https://api.github.com/repos/CommBank/humbug/languages","stargazers_url":"https://api.github.com/repos/CommBank/humbug/stargazers","contributors_url":"https://api.github.com/repos/CommBank/humbug/contributors","subscribers_url":"https://api.github.com/repos/CommBank/humbug/subscribers","subscription_url":"https://api.github.com/repos/CommBank/humbug/subscription","commits_url":"https://api.github.com/repos/CommBank/humbug/commits{/sha}","git_commits_url":"https://api.github.com/repos/CommBank/humbug/git/commits{/sha}","comments_url":"https://api.github.com/repos/CommBank/humbug/comments{/number}","issue_comment_url":"https://api.github.com/repos/CommBank/humbug/issues/comments{/number}","contents_url":"https://api.github.com/repos/CommBank/humbug/contents/{+path}","compare_url":"https://api.github.com/repos/CommBank/humbug/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CommBank/humbug/merges","archive_url":"https://api.github.com/repos/CommBank/humbug/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CommBank/humbug/downloads","issues_url":"https://api.github.com/repos/CommBank/humbug/issues{/number}","pulls_url":"https://api.github.com/repos/CommBank/humbug/pulls{/number}","milestones_url":"https://api.github.com/repos/CommBank/humbug/milestones{/number}","notifications_url":"https://api.github.com/repos/CommBank/humbug/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CommBank/humbug/labels{/name}","releases_url":"https://api.github.com/repos/CommBank/humbug/releases{/id}","created_at":"2014-05-04T23:54:10Z","updated_at":"2015-05-04T07:05:36Z","pushed_at":"2015-05-07T03:25:14Z","git_url":"git://github.com/CommBank/humbug.git","ssh_url":"git@github.com:CommBank/humbug.git","clone_url":"https://github.com/CommBank/humbug.git","svn_url":"https://github.com/CommBank/humbug","homepage":"https://commbank.github.io/humbug","size":2394,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CommBank/humbug/pulls/19"},"html":{"href":"https://github.com/CommBank/humbug/pull/19"},"issue":{"href":"https://api.github.com/repos/CommBank/humbug/issues/19"},"comments":{"href":"https://api.github.com/repos/CommBank/humbug/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/CommBank/humbug/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/CommBank/humbug/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CommBank/humbug/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/CommBank/humbug/statuses/5427fc856d2e845fc5a838cc26fd8816bc20aa46"}}}}