{"action":"opened","number":19,"pull_request":{"url":"https://api.github.com/repos/spazzarama/SharpDisasm/pulls/19","id":198920311,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4OTIwMzEx","html_url":"https://github.com/spazzarama/SharpDisasm/pull/19","diff_url":"https://github.com/spazzarama/SharpDisasm/pull/19.diff","patch_url":"https://github.com/spazzarama/SharpDisasm/pull/19.patch","issue_url":"https://api.github.com/repos/spazzarama/SharpDisasm/issues/19","number":19,"state":"open","locked":false,"title":"Interfacing 'Instruction' class ","user":{"login":"shlomoartsi","id":40729917,"node_id":"MDQ6VXNlcjQwNzI5OTE3","avatar_url":"https://avatars1.githubusercontent.com/u/40729917?v=4","gravatar_id":"","url":"https://api.github.com/users/shlomoartsi","html_url":"https://github.com/shlomoartsi","followers_url":"https://api.github.com/users/shlomoartsi/followers","following_url":"https://api.github.com/users/shlomoartsi/following{/other_user}","gists_url":"https://api.github.com/users/shlomoartsi/gists{/gist_id}","starred_url":"https://api.github.com/users/shlomoartsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shlomoartsi/subscriptions","organizations_url":"https://api.github.com/users/shlomoartsi/orgs","repos_url":"https://api.github.com/users/shlomoartsi/repos","events_url":"https://api.github.com/users/shlomoartsi/events{/privacy}","received_events_url":"https://api.github.com/users/shlomoartsi/received_events","type":"User","site_admin":false},"body":"A support is added to generate a different Instruction class (ie MyInstruction). For that we define an IInstruction interface for Instruction class. in addition a IInstructionFactory is injected to the ctor of Disassembler in order to generate a different class implementing IInstruction .\r\nThe backward compatibility is maintained, and if no implementation of IInstructionFactory is injected than an InstructionFactory class that generate the Instruction class is used.\r\n\r\nI've used your project for implementing a binary obfuscation project. For that i needed to add more info for Instruction class, such as previous and next instruction fields. I didn't want to add these fields on the project itself, but on my custom class that defines an instruction.\r\nI've found that the most structured way for doing this is to change the project to use interface of IInstruction instead of actual class of Instruction , and to use dependency injection for factory of IInstruction implementation instead of using \"new Instruction()\" where needed.\r\nAn example for the dependency injection is the Disassembler ctor. This injection allows the consumer of the project to have an actual control of the creation of Instruction class (and by the way promote the testablity of Disassembler class):\r\n\r\npublic Disassembler(IAssemblyCode code, ArchitectureMode architecture, ulong address = 0x0,\r\nbool copyBinaryToInstruction = false,\r\nVendor vendor = Vendor.Any, IInstructionFactory instructionFactory = null)\r\n{\r\n...\r\nif (instructionFactory == null)\r\n{\r\nthis.InstructionFactory = new InstructionFactory();\r\n}\r\nelse\r\n{\r\nthis.InstructionFactory = instructionFactory;\r\n}\r\n...\r\n}\r\n\r\nusing the factory:\r\n_public IInstruction NextInstruction()\r\n{\r\nint length = 0;\r\nif ((length = Udis86.udis86.ud_disassemble(ref u)) > 0)\r\n{\r\nvar instruction = InstructionFactory.Create(ref _u, CopyBinaryToInstruction);\r\nif (!instruction.Error)\r\n{\r\nBytesDecoded += length;\r\n}\r\nreturn instruction;\r\n}\r\nreturn null;\r\n}","created_at":"2018-07-03T10:36:21Z","updated_at":"2018-07-03T10:36:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/spazzarama/SharpDisasm/pulls/19/commits","review_comments_url":"https://api.github.com/repos/spazzarama/SharpDisasm/pulls/19/comments","review_comment_url":"https://api.github.com/repos/spazzarama/SharpDisasm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spazzarama/SharpDisasm/issues/19/comments","statuses_url":"https://api.github.com/repos/spazzarama/SharpDisasm/statuses/29ecabbbbb33d4216861ce467376292d27a14a2f","head":{"label":"spazzarama:develop","ref":"develop","sha":"29ecabbbbb33d4216861ce467376292d27a14a2f","user":{"login":"spazzarama","id":933730,"node_id":"MDQ6VXNlcjkzMzczMA==","avatar_url":"https://avatars3.githubusercontent.com/u/933730?v=4","gravatar_id":"","url":"https://api.github.com/users/spazzarama","html_url":"https://github.com/spazzarama","followers_url":"https://api.github.com/users/spazzarama/followers","following_url":"https://api.github.com/users/spazzarama/following{/other_user}","gists_url":"https://api.github.com/users/spazzarama/gists{/gist_id}","starred_url":"https://api.github.com/users/spazzarama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spazzarama/subscriptions","organizations_url":"https://api.github.com/users/spazzarama/orgs","repos_url":"https://api.github.com/users/spazzarama/repos","events_url":"https://api.github.com/users/spazzarama/events{/privacy}","received_events_url":"https://api.github.com/users/spazzarama/received_events","type":"User","site_admin":false},"repo":{"id":38908260,"node_id":"MDEwOlJlcG9zaXRvcnkzODkwODI2MA==","name":"SharpDisasm","full_name":"spazzarama/SharpDisasm","owner":{"login":"spazzarama","id":933730,"node_id":"MDQ6VXNlcjkzMzczMA==","avatar_url":"https://avatars3.githubusercontent.com/u/933730?v=4","gravatar_id":"","url":"https://api.github.com/users/spazzarama","html_url":"https://github.com/spazzarama","followers_url":"https://api.github.com/users/spazzarama/followers","following_url":"https://api.github.com/users/spazzarama/following{/other_user}","gists_url":"https://api.github.com/users/spazzarama/gists{/gist_id}","starred_url":"https://api.github.com/users/spazzarama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spazzarama/subscriptions","organizations_url":"https://api.github.com/users/spazzarama/orgs","repos_url":"https://api.github.com/users/spazzarama/repos","events_url":"https://api.github.com/users/spazzarama/events{/privacy}","received_events_url":"https://api.github.com/users/spazzarama/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/spazzarama/SharpDisasm","description":"SharpDisasm - x86 / x86-64 disassembler for .NET","fork":false,"url":"https://api.github.com/repos/spazzarama/SharpDisasm","forks_url":"https://api.github.com/repos/spazzarama/SharpDisasm/forks","keys_url":"https://api.github.com/repos/spazzarama/SharpDisasm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spazzarama/SharpDisasm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spazzarama/SharpDisasm/teams","hooks_url":"https://api.github.com/repos/spazzarama/SharpDisasm/hooks","issue_events_url":"https://api.github.com/repos/spazzarama/SharpDisasm/issues/events{/number}","events_url":"https://api.github.com/repos/spazzarama/SharpDisasm/events","assignees_url":"https://api.github.com/repos/spazzarama/SharpDisasm/assignees{/user}","branches_url":"https://api.github.com/repos/spazzarama/SharpDisasm/branches{/branch}","tags_url":"https://api.github.com/repos/spazzarama/SharpDisasm/tags","blobs_url":"https://api.github.com/repos/spazzarama/SharpDisasm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spazzarama/SharpDisasm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spazzarama/SharpDisasm/git/refs{/sha}","trees_url":"https://api.github.com/repos/spazzarama/SharpDisasm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spazzarama/SharpDisasm/statuses/{sha}","languages_url":"https://api.github.com/repos/spazzarama/SharpDisasm/languages","stargazers_url":"https://api.github.com/repos/spazzarama/SharpDisasm/stargazers","contributors_url":"https://api.github.com/repos/spazzarama/SharpDisasm/contributors","subscribers_url":"https://api.github.com/repos/spazzarama/SharpDisasm/subscribers","subscription_url":"https://api.github.com/repos/spazzarama/SharpDisasm/subscription","commits_url":"https://api.github.com/repos/spazzarama/SharpDisasm/commits{/sha}","git_commits_url":"https://api.github.com/repos/spazzarama/SharpDisasm/git/commits{/sha}","comments_url":"https://api.github.com/repos/spazzarama/SharpDisasm/comments{/number}","issue_comment_url":"https://api.github.com/repos/spazzarama/SharpDisasm/issues/comments{/number}","contents_url":"https://api.github.com/repos/spazzarama/SharpDisasm/contents/{+path}","compare_url":"https://api.github.com/repos/spazzarama/SharpDisasm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spazzarama/SharpDisasm/merges","archive_url":"https://api.github.com/repos/spazzarama/SharpDisasm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spazzarama/SharpDisasm/downloads","issues_url":"https://api.github.com/repos/spazzarama/SharpDisasm/issues{/number}","pulls_url":"https://api.github.com/repos/spazzarama/SharpDisasm/pulls{/number}","milestones_url":"https://api.github.com/repos/spazzarama/SharpDisasm/milestones{/number}","notifications_url":"https://api.github.com/repos/spazzarama/SharpDisasm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spazzarama/SharpDisasm/labels{/name}","releases_url":"https://api.github.com/repos/spazzarama/SharpDisasm/releases{/id}","deployments_url":"https://api.github.com/repos/spazzarama/SharpDisasm/deployments","created_at":"2015-07-11T00:52:09Z","updated_at":"2018-07-01T12:02:24Z","pushed_at":"2018-07-02T09:40:49Z","git_url":"git://github.com/spazzarama/SharpDisasm.git","ssh_url":"git@github.com:spazzarama/SharpDisasm.git","clone_url":"https://github.com/spazzarama/SharpDisasm.git","svn_url":"https://github.com/spazzarama/SharpDisasm","homepage":"https://www.nuget.org/packages/SharpDisasm","size":303,"stargazers_count":69,"watchers_count":69,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":13,"open_issues":3,"watchers":69,"default_branch":"master"}},"base":{"label":"spazzarama:master","ref":"master","sha":"ee3af3d8aaec755208aa6782aa0eae51fd90165b","user":{"login":"spazzarama","id":933730,"node_id":"MDQ6VXNlcjkzMzczMA==","avatar_url":"https://avatars3.githubusercontent.com/u/933730?v=4","gravatar_id":"","url":"https://api.github.com/users/spazzarama","html_url":"https://github.com/spazzarama","followers_url":"https://api.github.com/users/spazzarama/followers","following_url":"https://api.github.com/users/spazzarama/following{/other_user}","gists_url":"https://api.github.com/users/spazzarama/gists{/gist_id}","starred_url":"https://api.github.com/users/spazzarama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spazzarama/subscriptions","organizations_url":"https://api.github.com/users/spazzarama/orgs","repos_url":"https://api.github.com/users/spazzarama/repos","events_url":"https://api.github.com/users/spazzarama/events{/privacy}","received_events_url":"https://api.github.com/users/spazzarama/received_events","type":"User","site_admin":false},"repo":{"id":38908260,"node_id":"MDEwOlJlcG9zaXRvcnkzODkwODI2MA==","name":"SharpDisasm","full_name":"spazzarama/SharpDisasm","owner":{"login":"spazzarama","id":933730,"node_id":"MDQ6VXNlcjkzMzczMA==","avatar_url":"https://avatars3.githubusercontent.com/u/933730?v=4","gravatar_id":"","url":"https://api.github.com/users/spazzarama","html_url":"https://github.com/spazzarama","followers_url":"https://api.github.com/users/spazzarama/followers","following_url":"https://api.github.com/users/spazzarama/following{/other_user}","gists_url":"https://api.github.com/users/spazzarama/gists{/gist_id}","starred_url":"https://api.github.com/users/spazzarama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spazzarama/subscriptions","organizations_url":"https://api.github.com/users/spazzarama/orgs","repos_url":"https://api.github.com/users/spazzarama/repos","events_url":"https://api.github.com/users/spazzarama/events{/privacy}","received_events_url":"https://api.github.com/users/spazzarama/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/spazzarama/SharpDisasm","description":"SharpDisasm - x86 / x86-64 disassembler for .NET","fork":false,"url":"https://api.github.com/repos/spazzarama/SharpDisasm","forks_url":"https://api.github.com/repos/spazzarama/SharpDisasm/forks","keys_url":"https://api.github.com/repos/spazzarama/SharpDisasm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spazzarama/SharpDisasm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spazzarama/SharpDisasm/teams","hooks_url":"https://api.github.com/repos/spazzarama/SharpDisasm/hooks","issue_events_url":"https://api.github.com/repos/spazzarama/SharpDisasm/issues/events{/number}","events_url":"https://api.github.com/repos/spazzarama/SharpDisasm/events","assignees_url":"https://api.github.com/repos/spazzarama/SharpDisasm/assignees{/user}","branches_url":"https://api.github.com/repos/spazzarama/SharpDisasm/branches{/branch}","tags_url":"https://api.github.com/repos/spazzarama/SharpDisasm/tags","blobs_url":"https://api.github.com/repos/spazzarama/SharpDisasm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spazzarama/SharpDisasm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spazzarama/SharpDisasm/git/refs{/sha}","trees_url":"https://api.github.com/repos/spazzarama/SharpDisasm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spazzarama/SharpDisasm/statuses/{sha}","languages_url":"https://api.github.com/repos/spazzarama/SharpDisasm/languages","stargazers_url":"https://api.github.com/repos/spazzarama/SharpDisasm/stargazers","contributors_url":"https://api.github.com/repos/spazzarama/SharpDisasm/contributors","subscribers_url":"https://api.github.com/repos/spazzarama/SharpDisasm/subscribers","subscription_url":"https://api.github.com/repos/spazzarama/SharpDisasm/subscription","commits_url":"https://api.github.com/repos/spazzarama/SharpDisasm/commits{/sha}","git_commits_url":"https://api.github.com/repos/spazzarama/SharpDisasm/git/commits{/sha}","comments_url":"https://api.github.com/repos/spazzarama/SharpDisasm/comments{/number}","issue_comment_url":"https://api.github.com/repos/spazzarama/SharpDisasm/issues/comments{/number}","contents_url":"https://api.github.com/repos/spazzarama/SharpDisasm/contents/{+path}","compare_url":"https://api.github.com/repos/spazzarama/SharpDisasm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spazzarama/SharpDisasm/merges","archive_url":"https://api.github.com/repos/spazzarama/SharpDisasm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spazzarama/SharpDisasm/downloads","issues_url":"https://api.github.com/repos/spazzarama/SharpDisasm/issues{/number}","pulls_url":"https://api.github.com/repos/spazzarama/SharpDisasm/pulls{/number}","milestones_url":"https://api.github.com/repos/spazzarama/SharpDisasm/milestones{/number}","notifications_url":"https://api.github.com/repos/spazzarama/SharpDisasm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spazzarama/SharpDisasm/labels{/name}","releases_url":"https://api.github.com/repos/spazzarama/SharpDisasm/releases{/id}","deployments_url":"https://api.github.com/repos/spazzarama/SharpDisasm/deployments","created_at":"2015-07-11T00:52:09Z","updated_at":"2018-07-01T12:02:24Z","pushed_at":"2018-07-02T09:40:49Z","git_url":"git://github.com/spazzarama/SharpDisasm.git","ssh_url":"git@github.com:spazzarama/SharpDisasm.git","clone_url":"https://github.com/spazzarama/SharpDisasm.git","svn_url":"https://github.com/spazzarama/SharpDisasm","homepage":"https://www.nuget.org/packages/SharpDisasm","size":303,"stargazers_count":69,"watchers_count":69,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":13,"open_issues":3,"watchers":69,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spazzarama/SharpDisasm/pulls/19"},"html":{"href":"https://github.com/spazzarama/SharpDisasm/pull/19"},"issue":{"href":"https://api.github.com/repos/spazzarama/SharpDisasm/issues/19"},"comments":{"href":"https://api.github.com/repos/spazzarama/SharpDisasm/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/spazzarama/SharpDisasm/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/spazzarama/SharpDisasm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spazzarama/SharpDisasm/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/spazzarama/SharpDisasm/statuses/29ecabbbbb33d4216861ce467376292d27a14a2f"}},"author_association":"NONE","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":1,"additions":74,"deletions":0,"changed_files":3}}
{"actor":{"display_login":"shlomoartsi"}}