{"action":"created","comment":{"url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/pulls/comments/62781064","id":62781064,"diff_hunk":"@@ -0,0 +1,152 @@\n+﻿using System.Collections.Immutable;\n+using System.Linq;\n+using Microsoft.CodeAnalysis;\n+using Microsoft.CodeAnalysis.CSharp;\n+using Microsoft.CodeAnalysis.CSharp.Syntax;\n+using Microsoft.CodeAnalysis.Diagnostics;\n+using VSDiagnostics.Utilities;\n+\n+namespace VSDiagnostics.Diagnostics.General.ImplementEqualsAndGetHashCode\n+{\n+    [DiagnosticAnalyzer(LanguageNames.CSharp)]\n+    public class ImplementEqualsAndGetHashCodeAnalyzer : DiagnosticAnalyzer\n+    {\n+        private const DiagnosticSeverity Severity = DiagnosticSeverity.Hidden;\n+\n+        private static readonly string Category = VSDiagnosticsResources.GeneralCategory;\n+        private static readonly string Message = VSDiagnosticsResources.ImplementEqualsAndGetHashCodeAnalyzerMessage;\n+        private static readonly string Title = VSDiagnosticsResources.ImplementEqualsAndGetHashCodeAnalyzerTitle;\n+\n+        internal static DiagnosticDescriptor Rule =>\n+            new DiagnosticDescriptor(DiagnosticId.ImplementEqualsAndGetHashCode, Title, Message, Category, Severity, true);\n+\n+        public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);\n+\n+        public override void Initialize(AnalysisContext context) =>\n+                context.RegisterSyntaxNodeAction(AnalyzeSymbol, SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration);\n+\n+        private void AnalyzeSymbol(SyntaxNodeAnalysisContext context)\n+        {\n+            var objectSymbol = context.SemanticModel.Compilation.GetSpecialType(SpecialType.System_Object);\n+            IMethodSymbol objectEquals = null;\n+            IMethodSymbol objectGetHashCode = null;\n+\n+            foreach (var symbol in objectSymbol.GetMembers())\n+            {\n+                if (!(symbol is IMethodSymbol))\n+                {\n+                    continue;\n+                }\n+\n+                var method = (IMethodSymbol)symbol;\n+                if (method.MetadataName == nameof(Equals) && method.Parameters.Count() == 1)\n+                {\n+                    objectEquals = method;\n+                }\n+\n+                if (method.MetadataName == nameof(GetHashCode) && !method.Parameters.Any())\n+                {\n+                    objectGetHashCode = method;\n+                }\n+            }\n+\n+            if (context.Node is ClassDeclarationSyntax)\n+            {\n+                var classDeclaration = (ClassDeclarationSyntax) context.Node;\n+\n+                if (MembersDoNotContainOverridenEqualsAndGetHashCode(context.SemanticModel, classDeclaration.Members, objectEquals, objectGetHashCode) &&\n+                    MembersContainNonStaticFieldOrProperty(classDeclaration.Members))\n+                {\n+                    context.ReportDiagnostic(Diagnostic.Create(Rule, classDeclaration.Identifier.GetLocation(), classDeclaration.Identifier));\n+                }\n+            }\n+            else\n+            {\n+                var structDeclaration = (StructDeclarationSyntax)context.Node;\n+\n+                if (MembersDoNotContainOverridenEqualsAndGetHashCode(context.SemanticModel, structDeclaration.Members, objectEquals, objectGetHashCode) &&\n+                    MembersContainNonStaticFieldOrProperty(structDeclaration.Members))\n+                {\n+                    context.ReportDiagnostic(Diagnostic.Create(Rule, structDeclaration.Identifier.GetLocation(), structDeclaration.Identifier));\n+                }\n+            }\n+        }\n+\n+        private bool MembersDoNotContainOverridenEqualsAndGetHashCode(SemanticModel model, SyntaxList<SyntaxNode> members, IMethodSymbol objectEquals, IMethodSymbol objectGetHashCode)","path":"VSDiagnostics/VSDiagnostics/VSDiagnostics/Diagnostics/General/ImplementEqualsAndGetHashCode/ImplementEqualsAndGetHashCodeAnalyzer.cs","position":75,"original_position":75,"commit_id":"64fef773aaf34a6b1af7348f309a6b571938876f","original_commit_id":"64fef773aaf34a6b1af7348f309a6b571938876f","user":{"login":"Vannevelj","id":2777107,"avatar_url":"https://avatars.githubusercontent.com/u/2777107?v=3","gravatar_id":"","url":"https://api.github.com/users/Vannevelj","html_url":"https://github.com/Vannevelj","followers_url":"https://api.github.com/users/Vannevelj/followers","following_url":"https://api.github.com/users/Vannevelj/following{/other_user}","gists_url":"https://api.github.com/users/Vannevelj/gists{/gist_id}","starred_url":"https://api.github.com/users/Vannevelj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vannevelj/subscriptions","organizations_url":"https://api.github.com/users/Vannevelj/orgs","repos_url":"https://api.github.com/users/Vannevelj/repos","events_url":"https://api.github.com/users/Vannevelj/events{/privacy}","received_events_url":"https://api.github.com/users/Vannevelj/received_events","type":"User","site_admin":false},"body":"Ah I see that now. Looked past it -- alright.","created_at":"2016-05-11T01:34:13Z","updated_at":"2016-05-11T01:34:13Z","html_url":"https://github.com/VSDiagnostics/VSDiagnostics/pull/556#discussion_r62781064","pull_request_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/pulls/556","_links":{"self":{"href":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/pulls/comments/62781064"},"html":{"href":"https://github.com/VSDiagnostics/VSDiagnostics/pull/556#discussion_r62781064"},"pull_request":{"href":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/pulls/556"}}},"pull_request":{"url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/pulls/556","id":68477275,"html_url":"https://github.com/VSDiagnostics/VSDiagnostics/pull/556","diff_url":"https://github.com/VSDiagnostics/VSDiagnostics/pull/556.diff","patch_url":"https://github.com/VSDiagnostics/VSDiagnostics/pull/556.patch","issue_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/issues/556","number":556,"state":"open","locked":false,"title":"Implement #477","user":{"login":"Hosch250","id":6299719,"avatar_url":"https://avatars.githubusercontent.com/u/6299719?v=3","gravatar_id":"","url":"https://api.github.com/users/Hosch250","html_url":"https://github.com/Hosch250","followers_url":"https://api.github.com/users/Hosch250/followers","following_url":"https://api.github.com/users/Hosch250/following{/other_user}","gists_url":"https://api.github.com/users/Hosch250/gists{/gist_id}","starred_url":"https://api.github.com/users/Hosch250/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hosch250/subscriptions","organizations_url":"https://api.github.com/users/Hosch250/orgs","repos_url":"https://api.github.com/users/Hosch250/repos","events_url":"https://api.github.com/users/Hosch250/events{/privacy}","received_events_url":"https://api.github.com/users/Hosch250/received_events","type":"User","site_admin":false},"body":"Close #477","created_at":"2016-04-30T19:54:09Z","updated_at":"2016-05-11T01:34:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59317ed03dba00dd3af47e4fe2c37d859a037bb1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/pulls/556/commits","review_comments_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/pulls/556/comments","review_comment_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/issues/556/comments","statuses_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/statuses/64fef773aaf34a6b1af7348f309a6b571938876f","head":{"label":"Hosch250:Feature477","ref":"Feature477","sha":"64fef773aaf34a6b1af7348f309a6b571938876f","user":{"login":"Hosch250","id":6299719,"avatar_url":"https://avatars.githubusercontent.com/u/6299719?v=3","gravatar_id":"","url":"https://api.github.com/users/Hosch250","html_url":"https://github.com/Hosch250","followers_url":"https://api.github.com/users/Hosch250/followers","following_url":"https://api.github.com/users/Hosch250/following{/other_user}","gists_url":"https://api.github.com/users/Hosch250/gists{/gist_id}","starred_url":"https://api.github.com/users/Hosch250/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hosch250/subscriptions","organizations_url":"https://api.github.com/users/Hosch250/orgs","repos_url":"https://api.github.com/users/Hosch250/repos","events_url":"https://api.github.com/users/Hosch250/events{/privacy}","received_events_url":"https://api.github.com/users/Hosch250/received_events","type":"User","site_admin":false},"repo":{"id":54166102,"name":"VSDiagnostics","full_name":"Hosch250/VSDiagnostics","owner":{"login":"Hosch250","id":6299719,"avatar_url":"https://avatars.githubusercontent.com/u/6299719?v=3","gravatar_id":"","url":"https://api.github.com/users/Hosch250","html_url":"https://github.com/Hosch250","followers_url":"https://api.github.com/users/Hosch250/followers","following_url":"https://api.github.com/users/Hosch250/following{/other_user}","gists_url":"https://api.github.com/users/Hosch250/gists{/gist_id}","starred_url":"https://api.github.com/users/Hosch250/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hosch250/subscriptions","organizations_url":"https://api.github.com/users/Hosch250/orgs","repos_url":"https://api.github.com/users/Hosch250/repos","events_url":"https://api.github.com/users/Hosch250/events{/privacy}","received_events_url":"https://api.github.com/users/Hosch250/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Hosch250/VSDiagnostics","description":"A collection of static analyzers based on Roslyn that integrate with VS","fork":true,"url":"https://api.github.com/repos/Hosch250/VSDiagnostics","forks_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/forks","keys_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/teams","hooks_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/hooks","issue_events_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/issues/events{/number}","events_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/events","assignees_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/assignees{/user}","branches_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/branches{/branch}","tags_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/tags","blobs_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/git/refs{/sha}","trees_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/statuses/{sha}","languages_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/languages","stargazers_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/stargazers","contributors_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/contributors","subscribers_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/subscribers","subscription_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/subscription","commits_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/commits{/sha}","git_commits_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/git/commits{/sha}","comments_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/comments{/number}","issue_comment_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/issues/comments{/number}","contents_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/contents/{+path}","compare_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/merges","archive_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/downloads","issues_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/issues{/number}","pulls_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/pulls{/number}","milestones_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/milestones{/number}","notifications_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/labels{/name}","releases_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/releases{/id}","deployments_url":"https://api.github.com/repos/Hosch250/VSDiagnostics/deployments","created_at":"2016-03-18T02:20:00Z","updated_at":"2016-03-18T02:20:01Z","pushed_at":"2016-05-10T03:01:24Z","git_url":"git://github.com/Hosch250/VSDiagnostics.git","ssh_url":"git@github.com:Hosch250/VSDiagnostics.git","clone_url":"https://github.com/Hosch250/VSDiagnostics.git","svn_url":"https://github.com/Hosch250/VSDiagnostics","homepage":"http://vsdiagnostics.github.io","size":1250,"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":"freshdevelop"}},"base":{"label":"VSDiagnostics:develop","ref":"develop","sha":"3d7d375c8016737576c44a2d518b32b9ed60bcf1","user":{"login":"VSDiagnostics","id":17017446,"avatar_url":"https://avatars.githubusercontent.com/u/17017446?v=3","gravatar_id":"","url":"https://api.github.com/users/VSDiagnostics","html_url":"https://github.com/VSDiagnostics","followers_url":"https://api.github.com/users/VSDiagnostics/followers","following_url":"https://api.github.com/users/VSDiagnostics/following{/other_user}","gists_url":"https://api.github.com/users/VSDiagnostics/gists{/gist_id}","starred_url":"https://api.github.com/users/VSDiagnostics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VSDiagnostics/subscriptions","organizations_url":"https://api.github.com/users/VSDiagnostics/orgs","repos_url":"https://api.github.com/users/VSDiagnostics/repos","events_url":"https://api.github.com/users/VSDiagnostics/events{/privacy}","received_events_url":"https://api.github.com/users/VSDiagnostics/received_events","type":"Organization","site_admin":false},"repo":{"id":34992631,"name":"VSDiagnostics","full_name":"VSDiagnostics/VSDiagnostics","owner":{"login":"VSDiagnostics","id":17017446,"avatar_url":"https://avatars.githubusercontent.com/u/17017446?v=3","gravatar_id":"","url":"https://api.github.com/users/VSDiagnostics","html_url":"https://github.com/VSDiagnostics","followers_url":"https://api.github.com/users/VSDiagnostics/followers","following_url":"https://api.github.com/users/VSDiagnostics/following{/other_user}","gists_url":"https://api.github.com/users/VSDiagnostics/gists{/gist_id}","starred_url":"https://api.github.com/users/VSDiagnostics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VSDiagnostics/subscriptions","organizations_url":"https://api.github.com/users/VSDiagnostics/orgs","repos_url":"https://api.github.com/users/VSDiagnostics/repos","events_url":"https://api.github.com/users/VSDiagnostics/events{/privacy}","received_events_url":"https://api.github.com/users/VSDiagnostics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VSDiagnostics/VSDiagnostics","description":"A collection of static analyzers based on Roslyn that integrate with VS","fork":false,"url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics","forks_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/forks","keys_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/teams","hooks_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/hooks","issue_events_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/issues/events{/number}","events_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/events","assignees_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/assignees{/user}","branches_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/branches{/branch}","tags_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/tags","blobs_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/git/refs{/sha}","trees_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/statuses/{sha}","languages_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/languages","stargazers_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/stargazers","contributors_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/contributors","subscribers_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/subscribers","subscription_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/subscription","commits_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/commits{/sha}","git_commits_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/git/commits{/sha}","comments_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/comments{/number}","issue_comment_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/issues/comments{/number}","contents_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/contents/{+path}","compare_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/merges","archive_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/downloads","issues_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/issues{/number}","pulls_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/pulls{/number}","milestones_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/milestones{/number}","notifications_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/labels{/name}","releases_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/releases{/id}","deployments_url":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/deployments","created_at":"2015-05-03T16:33:02Z","updated_at":"2016-05-05T10:31:46Z","pushed_at":"2016-05-10T03:01:24Z","git_url":"git://github.com/VSDiagnostics/VSDiagnostics.git","ssh_url":"git@github.com:VSDiagnostics/VSDiagnostics.git","clone_url":"https://github.com/VSDiagnostics/VSDiagnostics.git","svn_url":"https://github.com/VSDiagnostics/VSDiagnostics","homepage":"http://vsdiagnostics.github.io","size":1498,"stargazers_count":45,"watchers_count":45,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":187,"forks":9,"open_issues":187,"watchers":45,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/pulls/556"},"html":{"href":"https://github.com/VSDiagnostics/VSDiagnostics/pull/556"},"issue":{"href":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/issues/556"},"comments":{"href":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/issues/556/comments"},"review_comments":{"href":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/pulls/556/comments"},"review_comment":{"href":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/pulls/556/commits"},"statuses":{"href":"https://api.github.com/repos/VSDiagnostics/VSDiagnostics/statuses/64fef773aaf34a6b1af7348f309a6b571938876f"}}}}