{"action":"created","comment":{"url":"https://api.github.com/repos/Particular/NServiceBus/pulls/comments/72099101","id":72099101,"diff_hunk":"@@ -0,0 +1,102 @@\n+namespace NServiceBus.Core.Tests\n+{\n+    using System;\n+    using System.Collections.Generic;\n+    using System.Runtime.InteropServices;\n+    using System.Text;\n+    using ApprovalTests;\n+    using NUnit.Framework;\n+\n+    [TestFixture]\n+    public class StructConventionsTests\n+    {\n+        [Test]\n+        public void ApproveStructsWhichDontFollowStructGuidelines()\n+        {\n+            var approvalBuilder = new StringBuilder();\n+            approvalBuilder.AppendLine(@\"-------------------------------------------------- REMEMBER --------------------------------------------------\n+CONSIDER defining a struct instead of a class if instances of the type are small and commonly short-lived or are commonly embedded in other objects.\n+\n+AVOID defining a struct unless the type has all of the following characteristics:\n+   * It logically represents a single value, similar to primitive types(int, double, etc.).\n+   * It has an instance size under 16 bytes.\n+   * It is immutable.\n+   * It will not have to be boxed frequently.\n+\n+In all other cases, you should define your types as classes.\n+-------------------------------------------------- REMEMBER --------------------------------------------------\n+\");\n+\n+            var assembly = typeof(Endpoint).Assembly;\n+            foreach (var type in assembly.GetTypes())\n+            {\n+                if (!type.IsValueType || type.IsEnum) continue;\n+\n+                var offendedRules = new List<string> { $\"{type.FullName} violates the following rules:\" };\n+\n+                InspectSizeOfStruct(type, offendedRules);\n+                InspectMutabilityOfStruct(type, offendedRules);\n+\n+                if (offendedRules.Count <= 1) continue;\n+                foreach (var offendedRule in offendedRules)\n+                {\n+                    approvalBuilder.AppendLine(offendedRule);\n+                }\n+                approvalBuilder.AppendLine();\n+            }\n+\n+            Approvals.Verify(approvalBuilder.ToString());\n+        }\n+\n+        static void InspectMutabilityOfStruct(Type type, List<string> offendedRules)","path":"src/NServiceBus.Core.Tests/StructConventionsTests.cs","position":51,"original_position":51,"commit_id":"59468bff365a248ecc8e1e1f2e97325fdbc7e01c","original_commit_id":"59468bff365a248ecc8e1e1f2e97325fdbc7e01c","user":{"login":"danielmarbach","id":174258,"avatar_url":"https://avatars.githubusercontent.com/u/174258?v=3","gravatar_id":"","url":"https://api.github.com/users/danielmarbach","html_url":"https://github.com/danielmarbach","followers_url":"https://api.github.com/users/danielmarbach/followers","following_url":"https://api.github.com/users/danielmarbach/following{/other_user}","gists_url":"https://api.github.com/users/danielmarbach/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmarbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmarbach/subscriptions","organizations_url":"https://api.github.com/users/danielmarbach/orgs","repos_url":"https://api.github.com/users/danielmarbach/repos","events_url":"https://api.github.com/users/danielmarbach/events{/privacy}","received_events_url":"https://api.github.com/users/danielmarbach/received_events","type":"User","site_admin":false},"body":"It is a start. Then lets rename it\n\nOn Monday, July 25, 2016, Brandon Ording <notifications@github.com> wrote:\n\n> In src/NServiceBus.Core.Tests/StructConventionsTests.cs\n> <https://github.com/Particular/NServiceBus/pull/3963#discussion_r72095991>\n> :\n>\n> > +\n> > +                InspectSizeOfStruct(type, offendedRules);\n> > +                InspectMutabilityOfStruct(type, offendedRules);\n> > +\n> > +                if (offendedRules.Count <= 1) continue;\n> > +                foreach (var offendedRule in offendedRules)\n> > +                {\n> > +                    approvalBuilder.AppendLine(offendedRule);\n> > +                }\n> > +                approvalBuilder.AppendLine();\n> > +            }\n> > +\n> > +            Approvals.Verify(approvalBuilder.ToString());\n> > +        }\n> > +\n> > +        static void InspectMutabilityOfStruct(Type type, List<string> offendedRules)\n>\n> This appears to be misnamed, because it's actually looking to see if the\n> struct has any reference-type members. Being a class doesn't inherently\n> mean the type is mutable! Classes can be designed to be immutable as well.\n>\n> However. it seems like a true test of immutability would somewhat\n> difficult to write. The easy things would be to check for the presence of\n> public fields and properties with setters. I can't think of a way to verify\n> that a method doesn't mutate state, though.\n>\n> Perhaps it would be better to change the naming of this to a \"reference\n> type checker\" ?\n>\n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/Particular/NServiceBus/pull/3963/files/59468bff365a248ecc8e1e1f2e97325fdbc7e01c#r72095991>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/AAKoslhky-YfrK7kR3EA_lTpqELK3zLrks5qZOL2gaJpZM4JTWmG>\n> .\n>\n","created_at":"2016-07-25T16:41:05Z","updated_at":"2016-07-25T16:41:05Z","html_url":"https://github.com/Particular/NServiceBus/pull/3963#discussion_r72099101","pull_request_url":"https://api.github.com/repos/Particular/NServiceBus/pulls/3963","_links":{"self":{"href":"https://api.github.com/repos/Particular/NServiceBus/pulls/comments/72099101"},"html":{"href":"https://github.com/Particular/NServiceBus/pull/3963#discussion_r72099101"},"pull_request":{"href":"https://api.github.com/repos/Particular/NServiceBus/pulls/3963"}}},"pull_request":{"url":"https://api.github.com/repos/Particular/NServiceBus/pulls/3963","id":78571589,"html_url":"https://github.com/Particular/NServiceBus/pull/3963","diff_url":"https://github.com/Particular/NServiceBus/pull/3963.diff","patch_url":"https://github.com/Particular/NServiceBus/pull/3963.patch","issue_url":"https://api.github.com/repos/Particular/NServiceBus/issues/3963","number":3963,"state":"open","locked":false,"title":"[WIP] Structs which violate the recommended best practices need to get approved","user":{"login":"danielmarbach","id":174258,"avatar_url":"https://avatars.githubusercontent.com/u/174258?v=3","gravatar_id":"","url":"https://api.github.com/users/danielmarbach","html_url":"https://github.com/danielmarbach","followers_url":"https://api.github.com/users/danielmarbach/followers","following_url":"https://api.github.com/users/danielmarbach/following{/other_user}","gists_url":"https://api.github.com/users/danielmarbach/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmarbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmarbach/subscriptions","organizations_url":"https://api.github.com/users/danielmarbach/orgs","repos_url":"https://api.github.com/users/danielmarbach/repos","events_url":"https://api.github.com/users/danielmarbach/events{/privacy}","received_events_url":"https://api.github.com/users/danielmarbach/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-23T12:53:56Z","updated_at":"2016-07-25T16:41:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b7737e1a5cdc34f99f78d4da27177c0078773cb8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Particular/NServiceBus/pulls/3963/commits","review_comments_url":"https://api.github.com/repos/Particular/NServiceBus/pulls/3963/comments","review_comment_url":"https://api.github.com/repos/Particular/NServiceBus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Particular/NServiceBus/issues/3963/comments","statuses_url":"https://api.github.com/repos/Particular/NServiceBus/statuses/59468bff365a248ecc8e1e1f2e97325fdbc7e01c","head":{"label":"Particular:StructTest","ref":"StructTest","sha":"59468bff365a248ecc8e1e1f2e97325fdbc7e01c","user":{"login":"Particular","id":5038441,"avatar_url":"https://avatars.githubusercontent.com/u/5038441?v=3","gravatar_id":"","url":"https://api.github.com/users/Particular","html_url":"https://github.com/Particular","followers_url":"https://api.github.com/users/Particular/followers","following_url":"https://api.github.com/users/Particular/following{/other_user}","gists_url":"https://api.github.com/users/Particular/gists{/gist_id}","starred_url":"https://api.github.com/users/Particular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Particular/subscriptions","organizations_url":"https://api.github.com/users/Particular/orgs","repos_url":"https://api.github.com/users/Particular/repos","events_url":"https://api.github.com/users/Particular/events{/privacy}","received_events_url":"https://api.github.com/users/Particular/received_events","type":"Organization","site_admin":false},"repo":{"id":1056713,"name":"NServiceBus","full_name":"Particular/NServiceBus","owner":{"login":"Particular","id":5038441,"avatar_url":"https://avatars.githubusercontent.com/u/5038441?v=3","gravatar_id":"","url":"https://api.github.com/users/Particular","html_url":"https://github.com/Particular","followers_url":"https://api.github.com/users/Particular/followers","following_url":"https://api.github.com/users/Particular/following{/other_user}","gists_url":"https://api.github.com/users/Particular/gists{/gist_id}","starred_url":"https://api.github.com/users/Particular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Particular/subscriptions","organizations_url":"https://api.github.com/users/Particular/orgs","repos_url":"https://api.github.com/users/Particular/repos","events_url":"https://api.github.com/users/Particular/events{/privacy}","received_events_url":"https://api.github.com/users/Particular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Particular/NServiceBus","description":"The most popular service bus for .NET","fork":false,"url":"https://api.github.com/repos/Particular/NServiceBus","forks_url":"https://api.github.com/repos/Particular/NServiceBus/forks","keys_url":"https://api.github.com/repos/Particular/NServiceBus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Particular/NServiceBus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Particular/NServiceBus/teams","hooks_url":"https://api.github.com/repos/Particular/NServiceBus/hooks","issue_events_url":"https://api.github.com/repos/Particular/NServiceBus/issues/events{/number}","events_url":"https://api.github.com/repos/Particular/NServiceBus/events","assignees_url":"https://api.github.com/repos/Particular/NServiceBus/assignees{/user}","branches_url":"https://api.github.com/repos/Particular/NServiceBus/branches{/branch}","tags_url":"https://api.github.com/repos/Particular/NServiceBus/tags","blobs_url":"https://api.github.com/repos/Particular/NServiceBus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Particular/NServiceBus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Particular/NServiceBus/git/refs{/sha}","trees_url":"https://api.github.com/repos/Particular/NServiceBus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Particular/NServiceBus/statuses/{sha}","languages_url":"https://api.github.com/repos/Particular/NServiceBus/languages","stargazers_url":"https://api.github.com/repos/Particular/NServiceBus/stargazers","contributors_url":"https://api.github.com/repos/Particular/NServiceBus/contributors","subscribers_url":"https://api.github.com/repos/Particular/NServiceBus/subscribers","subscription_url":"https://api.github.com/repos/Particular/NServiceBus/subscription","commits_url":"https://api.github.com/repos/Particular/NServiceBus/commits{/sha}","git_commits_url":"https://api.github.com/repos/Particular/NServiceBus/git/commits{/sha}","comments_url":"https://api.github.com/repos/Particular/NServiceBus/comments{/number}","issue_comment_url":"https://api.github.com/repos/Particular/NServiceBus/issues/comments{/number}","contents_url":"https://api.github.com/repos/Particular/NServiceBus/contents/{+path}","compare_url":"https://api.github.com/repos/Particular/NServiceBus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Particular/NServiceBus/merges","archive_url":"https://api.github.com/repos/Particular/NServiceBus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Particular/NServiceBus/downloads","issues_url":"https://api.github.com/repos/Particular/NServiceBus/issues{/number}","pulls_url":"https://api.github.com/repos/Particular/NServiceBus/pulls{/number}","milestones_url":"https://api.github.com/repos/Particular/NServiceBus/milestones{/number}","notifications_url":"https://api.github.com/repos/Particular/NServiceBus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Particular/NServiceBus/labels{/name}","releases_url":"https://api.github.com/repos/Particular/NServiceBus/releases{/id}","deployments_url":"https://api.github.com/repos/Particular/NServiceBus/deployments","created_at":"2010-11-06T12:54:52Z","updated_at":"2016-07-25T14:32:54Z","pushed_at":"2016-07-25T14:43:13Z","git_url":"git://github.com/Particular/NServiceBus.git","ssh_url":"git@github.com:Particular/NServiceBus.git","clone_url":"https://github.com/Particular/NServiceBus.git","svn_url":"https://github.com/Particular/NServiceBus","homepage":"http://particular.net/nservicebus","size":178877,"stargazers_count":946,"watchers_count":946,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":508,"mirror_url":null,"open_issues_count":239,"forks":508,"open_issues":239,"watchers":946,"default_branch":"develop"}},"base":{"label":"Particular:release-6.0.0","ref":"release-6.0.0","sha":"a0690287501ba4d7a91cc81d359b9f1bd65c6e0d","user":{"login":"Particular","id":5038441,"avatar_url":"https://avatars.githubusercontent.com/u/5038441?v=3","gravatar_id":"","url":"https://api.github.com/users/Particular","html_url":"https://github.com/Particular","followers_url":"https://api.github.com/users/Particular/followers","following_url":"https://api.github.com/users/Particular/following{/other_user}","gists_url":"https://api.github.com/users/Particular/gists{/gist_id}","starred_url":"https://api.github.com/users/Particular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Particular/subscriptions","organizations_url":"https://api.github.com/users/Particular/orgs","repos_url":"https://api.github.com/users/Particular/repos","events_url":"https://api.github.com/users/Particular/events{/privacy}","received_events_url":"https://api.github.com/users/Particular/received_events","type":"Organization","site_admin":false},"repo":{"id":1056713,"name":"NServiceBus","full_name":"Particular/NServiceBus","owner":{"login":"Particular","id":5038441,"avatar_url":"https://avatars.githubusercontent.com/u/5038441?v=3","gravatar_id":"","url":"https://api.github.com/users/Particular","html_url":"https://github.com/Particular","followers_url":"https://api.github.com/users/Particular/followers","following_url":"https://api.github.com/users/Particular/following{/other_user}","gists_url":"https://api.github.com/users/Particular/gists{/gist_id}","starred_url":"https://api.github.com/users/Particular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Particular/subscriptions","organizations_url":"https://api.github.com/users/Particular/orgs","repos_url":"https://api.github.com/users/Particular/repos","events_url":"https://api.github.com/users/Particular/events{/privacy}","received_events_url":"https://api.github.com/users/Particular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Particular/NServiceBus","description":"The most popular service bus for .NET","fork":false,"url":"https://api.github.com/repos/Particular/NServiceBus","forks_url":"https://api.github.com/repos/Particular/NServiceBus/forks","keys_url":"https://api.github.com/repos/Particular/NServiceBus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Particular/NServiceBus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Particular/NServiceBus/teams","hooks_url":"https://api.github.com/repos/Particular/NServiceBus/hooks","issue_events_url":"https://api.github.com/repos/Particular/NServiceBus/issues/events{/number}","events_url":"https://api.github.com/repos/Particular/NServiceBus/events","assignees_url":"https://api.github.com/repos/Particular/NServiceBus/assignees{/user}","branches_url":"https://api.github.com/repos/Particular/NServiceBus/branches{/branch}","tags_url":"https://api.github.com/repos/Particular/NServiceBus/tags","blobs_url":"https://api.github.com/repos/Particular/NServiceBus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Particular/NServiceBus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Particular/NServiceBus/git/refs{/sha}","trees_url":"https://api.github.com/repos/Particular/NServiceBus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Particular/NServiceBus/statuses/{sha}","languages_url":"https://api.github.com/repos/Particular/NServiceBus/languages","stargazers_url":"https://api.github.com/repos/Particular/NServiceBus/stargazers","contributors_url":"https://api.github.com/repos/Particular/NServiceBus/contributors","subscribers_url":"https://api.github.com/repos/Particular/NServiceBus/subscribers","subscription_url":"https://api.github.com/repos/Particular/NServiceBus/subscription","commits_url":"https://api.github.com/repos/Particular/NServiceBus/commits{/sha}","git_commits_url":"https://api.github.com/repos/Particular/NServiceBus/git/commits{/sha}","comments_url":"https://api.github.com/repos/Particular/NServiceBus/comments{/number}","issue_comment_url":"https://api.github.com/repos/Particular/NServiceBus/issues/comments{/number}","contents_url":"https://api.github.com/repos/Particular/NServiceBus/contents/{+path}","compare_url":"https://api.github.com/repos/Particular/NServiceBus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Particular/NServiceBus/merges","archive_url":"https://api.github.com/repos/Particular/NServiceBus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Particular/NServiceBus/downloads","issues_url":"https://api.github.com/repos/Particular/NServiceBus/issues{/number}","pulls_url":"https://api.github.com/repos/Particular/NServiceBus/pulls{/number}","milestones_url":"https://api.github.com/repos/Particular/NServiceBus/milestones{/number}","notifications_url":"https://api.github.com/repos/Particular/NServiceBus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Particular/NServiceBus/labels{/name}","releases_url":"https://api.github.com/repos/Particular/NServiceBus/releases{/id}","deployments_url":"https://api.github.com/repos/Particular/NServiceBus/deployments","created_at":"2010-11-06T12:54:52Z","updated_at":"2016-07-25T14:32:54Z","pushed_at":"2016-07-25T14:43:13Z","git_url":"git://github.com/Particular/NServiceBus.git","ssh_url":"git@github.com:Particular/NServiceBus.git","clone_url":"https://github.com/Particular/NServiceBus.git","svn_url":"https://github.com/Particular/NServiceBus","homepage":"http://particular.net/nservicebus","size":178877,"stargazers_count":946,"watchers_count":946,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":508,"mirror_url":null,"open_issues_count":239,"forks":508,"open_issues":239,"watchers":946,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Particular/NServiceBus/pulls/3963"},"html":{"href":"https://github.com/Particular/NServiceBus/pull/3963"},"issue":{"href":"https://api.github.com/repos/Particular/NServiceBus/issues/3963"},"comments":{"href":"https://api.github.com/repos/Particular/NServiceBus/issues/3963/comments"},"review_comments":{"href":"https://api.github.com/repos/Particular/NServiceBus/pulls/3963/comments"},"review_comment":{"href":"https://api.github.com/repos/Particular/NServiceBus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Particular/NServiceBus/pulls/3963/commits"},"statuses":{"href":"https://api.github.com/repos/Particular/NServiceBus/statuses/59468bff365a248ecc8e1e1f2e97325fdbc7e01c"}}}}
{"actor":{"display_login":"danielmarbach"}}