{"action":"created","comment":{"url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/pulls/comments/37020307","id":37020307,"diff_hunk":"@@ -0,0 +1,93 @@\n+﻿using System;\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+\n+namespace VSDiagnostics.Diagnostics.General.FlagsEnumValuesAreNotPowersOfTwo\n+{\n+    [DiagnosticAnalyzer(LanguageNames.CSharp)]\n+    public class FlagsEnumValuesAreNotPowersOfTwoAnalyzer : DiagnosticAnalyzer\n+    {\n+        private const string DiagnosticId = nameof(FlagsEnumValuesAreNotPowersOfTwoAnalyzer);\n+        private const DiagnosticSeverity Severity = DiagnosticSeverity.Error;\n+\n+        private static readonly string Category = VSDiagnosticsResources.GeneralCategory;\n+        private static readonly string Message = VSDiagnosticsResources.FlagsEnumValuesAreNotPowersOfTwoAnalyzerMessage;\n+        private static readonly string Title = VSDiagnosticsResources.FlagsEnumValuesAreNotPowersOfTwoAnalyzerTitle;\n+\n+        internal static DiagnosticDescriptor Rule => new DiagnosticDescriptor(DiagnosticId, Title, Message, Category, Severity, true);\n+\n+        public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);\n+\n+        public override void Initialize(AnalysisContext context)\n+        {\n+            context.RegisterSyntaxNodeAction(AnalyzeSymbol, SyntaxKind.EnumDeclaration);\n+        }\n+\n+        private void AnalyzeSymbol(SyntaxNodeAnalysisContext context)\n+        {\n+            var declarationExpression = context.Node as EnumDeclarationSyntax;\n+            if (declarationExpression == null)\n+            {\n+                return;\n+            }\n+\n+            if (!declarationExpression.AttributeLists.Any(\n+                    a => a.Attributes.Any(\n+                        t => context.SemanticModel.GetSymbolInfo(t).Symbol.ContainingType.MetadataName == typeof(FlagsAttribute).Name)))\n+            {\n+                return;\n+            }\n+\n+            var enumMemberDeclarations = declarationExpression.ChildNodes().OfType<EnumMemberDeclarationSyntax>().ToList();\n+            var values = enumMemberDeclarations.Select(member => member.EqualsValue);\n+\n+            foreach (var equalsValue in values)\n+            {\n+                if (equalsValue == null)\n+                {\n+                    var enumName = context.SemanticModel.GetDeclaredSymbol(declarationExpression).Name;\n+                    context.ReportDiagnostic(Diagnostic.Create(Rule, declarationExpression.GetLocation(), enumName));\n+                    return;\n+                }\n+\n+                LiteralExpressionSyntax valueExpression = null;\n+\n+                if (equalsValue.Value is LiteralExpressionSyntax)\n+                {\n+                    valueExpression = (LiteralExpressionSyntax) equalsValue.Value;\n+                }\n+                if (equalsValue.Value is PrefixUnaryExpressionSyntax)","path":"VSDiagnostics/VSDiagnostics/VSDiagnostics/Diagnostics/General/FlagsEnumValuesAreNotPowersOfTwo/FlagsEnumValuesAreNotPowersOfTwoAnalyzer.cs","position":63,"original_position":63,"commit_id":"1f7c457e52761047fe8eaaa188df17fc00a54585","original_commit_id":"1f7c457e52761047fe8eaaa188df17fc00a54585","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":"Can you add some general commentary in certain places to make clear what scenario you're checking for at that particular point?","created_at":"2015-08-13T20:18:52Z","updated_at":"2015-08-13T20:18:52Z","html_url":"https://github.com/Vannevelj/VSDiagnostics/pull/147#discussion_r37020307","pull_request_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/pulls/147","_links":{"self":{"href":"https://api.github.com/repos/Vannevelj/VSDiagnostics/pulls/comments/37020307"},"html":{"href":"https://github.com/Vannevelj/VSDiagnostics/pull/147#discussion_r37020307"},"pull_request":{"href":"https://api.github.com/repos/Vannevelj/VSDiagnostics/pulls/147"}}},"pull_request":{"url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/pulls/147","id":42387665,"html_url":"https://github.com/Vannevelj/VSDiagnostics/pull/147","diff_url":"https://github.com/Vannevelj/VSDiagnostics/pull/147.diff","patch_url":"https://github.com/Vannevelj/VSDiagnostics/pull/147.patch","issue_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/issues/147","number":147,"state":"open","locked":false,"title":"Close #143","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 #143  ","created_at":"2015-08-13T19:14:38Z","updated_at":"2015-08-13T20:18:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0d26692925542e948c4963e54f2423d38f8cc77f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/pulls/147/commits","review_comments_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/pulls/147/comments","review_comment_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/issues/147/comments","statuses_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/statuses/1f7c457e52761047fe8eaaa188df17fc00a54585","head":{"label":"Hosch250:master","ref":"master","sha":"1f7c457e52761047fe8eaaa188df17fc00a54585","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":40224079,"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 code-quality analyzers","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}","created_at":"2015-08-05T04:22:50Z","updated_at":"2015-08-05T04:23:09Z","pushed_at":"2015-08-13T19:10:43Z","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":null,"size":596,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"Vannevelj:develop","ref":"develop","sha":"8d785e436a21a53c590a0581ec7942eb0c066e2c","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},"repo":{"id":34992631,"name":"VSDiagnostics","full_name":"Vannevelj/VSDiagnostics","owner":{"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},"private":false,"html_url":"https://github.com/Vannevelj/VSDiagnostics","description":"A collection of code-quality analyzers","fork":false,"url":"https://api.github.com/repos/Vannevelj/VSDiagnostics","forks_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/forks","keys_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/teams","hooks_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/hooks","issue_events_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/issues/events{/number}","events_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/events","assignees_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/assignees{/user}","branches_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/branches{/branch}","tags_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/tags","blobs_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/git/refs{/sha}","trees_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/statuses/{sha}","languages_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/languages","stargazers_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/stargazers","contributors_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/contributors","subscribers_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/subscribers","subscription_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/subscription","commits_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/commits{/sha}","git_commits_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/git/commits{/sha}","comments_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/comments{/number}","issue_comment_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/issues/comments{/number}","contents_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/contents/{+path}","compare_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/merges","archive_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/downloads","issues_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/issues{/number}","pulls_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/pulls{/number}","milestones_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/milestones{/number}","notifications_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/labels{/name}","releases_url":"https://api.github.com/repos/Vannevelj/VSDiagnostics/releases{/id}","created_at":"2015-05-03T16:33:02Z","updated_at":"2015-07-17T21:31:08Z","pushed_at":"2015-08-13T19:14:38Z","git_url":"git://github.com/Vannevelj/VSDiagnostics.git","ssh_url":"git@github.com:Vannevelj/VSDiagnostics.git","clone_url":"https://github.com/Vannevelj/VSDiagnostics.git","svn_url":"https://github.com/Vannevelj/VSDiagnostics","homepage":null,"size":1119,"stargazers_count":20,"watchers_count":20,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":34,"forks":7,"open_issues":34,"watchers":20,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Vannevelj/VSDiagnostics/pulls/147"},"html":{"href":"https://github.com/Vannevelj/VSDiagnostics/pull/147"},"issue":{"href":"https://api.github.com/repos/Vannevelj/VSDiagnostics/issues/147"},"comments":{"href":"https://api.github.com/repos/Vannevelj/VSDiagnostics/issues/147/comments"},"review_comments":{"href":"https://api.github.com/repos/Vannevelj/VSDiagnostics/pulls/147/comments"},"review_comment":{"href":"https://api.github.com/repos/Vannevelj/VSDiagnostics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Vannevelj/VSDiagnostics/pulls/147/commits"},"statuses":{"href":"https://api.github.com/repos/Vannevelj/VSDiagnostics/statuses/1f7c457e52761047fe8eaaa188df17fc00a54585"}}}}