{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/31366191","id":31366191,"diff_hunk":"@@ -174,6 +174,26 @@\n   <data name=\"InvalidSyntaxKindTypeArgumentDescription\" xml:space=\"preserve\">\n     <value>DiagnosticAnalyzer's language-specific Register methods, such as RegisterSyntaxNodeAction, RegisterCodeBlockStartAction and RegisterCodeBlockEndAction, expect a language-specific 'SyntaxKind' type argument for it's '{0}' type parameter. Otherwise, the registered analyzer action can never be invoked during analysis.</value>\n   </data>\n+  <data name=\"StartActionWithOnlyEndActionTitle\" xml:space=\"preserve\">\n+    <value>Start action has no registered non-end actions.</value>\n+  </data>\n+  <data name=\"StartActionWithNoRegisteredActionsMessage\" xml:space=\"preserve\">\n+    <value>You did not register any analyzer action on '{0}'. Move all the action registrations in '{1}' that depend on this start action onto '{0}'.</value>\n+  </data>\n+  <data name=\"StartActionWithNoRegisteredActionsTitle\" xml:space=\"preserve\">\n+    <value>Start action has no registered actions.</value>\n+  </data>\n+  <data name=\"StartActionWithOnlyEndActionMessage\" xml:space=\"preserve\">\n+    <value>You did not register any analyzer action on '{0}', except for a '{1}'. Either replace this start/end action pair with a '{2}' or move all the action registrations in '{3}' that depend on this start action onto '{0}'.</value>\n+  </data>\n+  <data name=\"StatefulAnalyzerRegisterActionsDescription\" xml:space=\"preserve\">\n+    <value>An analyzer start action enables performing stateful analysis over a given code unit, such as a code block, compilation, etc in a performant way. However, incorrect design for such analyzers can lead to memory leaks and non-performant analyzer execution. Use the following guidelines for writing such analyzers:\n+1. Define a new scope for the registered start action, possibly with a private nested type for analyzing each code unit.\n+2. If required, define and intialize state object(s) in the start action within this scope.\n+3. Register intermediate non-end actions in the start action, that depend upon and/or modify this state. You must register at least one such action. If there are no dependent intermediate actions for a start action, then the start action should be replaced by a corresponding non-start action. For example, a CodeBlockStartAction with no registered actions or only a registered CodeBlockEndAction should be replaced with a CodeBlockAction.","path":"src/Diagnostics/CodeAnalysis/Core/CodeAnalysisDiagnosticsResources.resx","position":20,"original_position":20,"commit_id":"09c5d7ac20bfee71d6cf415b8dc304c2f38ecfcb","original_commit_id":"09c5d7ac20bfee71d6cf415b8dc304c2f38ecfcb","user":{"login":"JohnHamby","id":10982715,"avatar_url":"https://avatars.githubusercontent.com/u/10982715?v=3","gravatar_id":"","url":"https://api.github.com/users/JohnHamby","html_url":"https://github.com/JohnHamby","followers_url":"https://api.github.com/users/JohnHamby/followers","following_url":"https://api.github.com/users/JohnHamby/following{/other_user}","gists_url":"https://api.github.com/users/JohnHamby/gists{/gist_id}","starred_url":"https://api.github.com/users/JohnHamby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohnHamby/subscriptions","organizations_url":"https://api.github.com/users/JohnHamby/orgs","repos_url":"https://api.github.com/users/JohnHamby/repos","events_url":"https://api.github.com/users/JohnHamby/events{/privacy}","received_events_url":"https://api.github.com/users/JohnHamby/received_events","type":"User","site_admin":false},"body":"How about something like:\r\n\r\nRegister at least one non-end action that refers to this state in the start action. If no such action is necessary, consider replacing the start action with a non-start action.\r\n\r\n?","created_at":"2015-05-29T21:24:35Z","updated_at":"2015-05-29T21:24:35Z","html_url":"https://github.com/dotnet/roslyn/pull/3162#discussion_r31366191","pull_request_url":"https://api.github.com/repos/dotnet/roslyn/pulls/3162","_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/31366191"},"html":{"href":"https://github.com/dotnet/roslyn/pull/3162#discussion_r31366191"},"pull_request":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/3162"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/3162","id":36461938,"html_url":"https://github.com/dotnet/roslyn/pull/3162","diff_url":"https://github.com/dotnet/roslyn/pull/3162.diff","patch_url":"https://github.com/dotnet/roslyn/pull/3162.patch","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/3162","number":3162,"state":"open","locked":false,"title":"Add an analyzer to CodeAnalysis analyzers package that detects incorr…","user":{"login":"mavasani","id":10605811,"avatar_url":"https://avatars.githubusercontent.com/u/10605811?v=3","gravatar_id":"","url":"https://api.github.com/users/mavasani","html_url":"https://github.com/mavasani","followers_url":"https://api.github.com/users/mavasani/followers","following_url":"https://api.github.com/users/mavasani/following{/other_user}","gists_url":"https://api.github.com/users/mavasani/gists{/gist_id}","starred_url":"https://api.github.com/users/mavasani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mavasani/subscriptions","organizations_url":"https://api.github.com/users/mavasani/orgs","repos_url":"https://api.github.com/users/mavasani/repos","events_url":"https://api.github.com/users/mavasani/events{/privacy}","received_events_url":"https://api.github.com/users/mavasani/received_events","type":"User","site_admin":false},"body":"…ect action registrations for stateful analyzers.\r\n\r\n**Fixes #2949**\r\n\r\n**User scenario:** User writes an analyzer that either defines a CompilationStartAction or CodeBlockStartAction to perform stateful analysis on the compilation/code block.\r\nAn analyzer start action enables performing stateful analysis over a given code unit in a performant way. However, incorrect design for such analyzers can lead to memory leaks and non-performant analyzer execution. This analyzer flags these cases and provides following guidelines for writing such stateful analyzers:\r\n\r\n1. Define a new scope for the registered start action, possibly with a private nested type for analyzing each code unit.\r\n\r\n2. If required, define and intialize state object(s) in the start action within this scope.\r\n\r\n3. Register intermediate non-end actions in the start action, that depend upon and/or modify this state. You must register at least one such action. If there are no dependent intermediate actions for a start action, then the start action should be replaced by a corresponding non-start action. For example, a CodeBlockStartAction with no registered actions or only a registered CodeBlockEndAction should be replaced with a CodeBlockAction.\r\n\r\n4. If required, register an end action to report diagnostics based on the final state.\r\n\r\n**Fix description:** We already have an analyzer flagging RegisterXXXAction invocations for other incorrect usages. This change adds 2 more rules to this analyzer to flag:\r\n\r\n1. Start analysis context objects with only a registered end action.\r\n\r\n2. Start analysis context objects with no registered nested actions.\r\n\r\n**Testing:** Added unit tests for this analyzer + manual testing. Verified existing tests pass.\r\n\r\n/cc @ManishJayaswal @srivatsn This is for 1.0 (stable)","created_at":"2015-05-28T23:39:32Z","updated_at":"2015-05-29T21:24:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"64e442ac01424740f3529ab6e51f6dbf8a6ef96c","assignee":{"login":"MattGertz","id":10520126,"avatar_url":"https://avatars.githubusercontent.com/u/10520126?v=3","gravatar_id":"","url":"https://api.github.com/users/MattGertz","html_url":"https://github.com/MattGertz","followers_url":"https://api.github.com/users/MattGertz/followers","following_url":"https://api.github.com/users/MattGertz/following{/other_user}","gists_url":"https://api.github.com/users/MattGertz/gists{/gist_id}","starred_url":"https://api.github.com/users/MattGertz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MattGertz/subscriptions","organizations_url":"https://api.github.com/users/MattGertz/orgs","repos_url":"https://api.github.com/users/MattGertz/repos","events_url":"https://api.github.com/users/MattGertz/events{/privacy}","received_events_url":"https://api.github.com/users/MattGertz/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/dotnet/roslyn/milestones/1","html_url":"https://github.com/dotnet/roslyn/milestones/1.0%20(stable)","labels_url":"https://api.github.com/repos/dotnet/roslyn/milestones/1/labels","id":937397,"number":1,"title":"1.0 (stable)","description":"This is our 1.0 Milestone. ","creator":{"login":"jaredpar","id":146967,"avatar_url":"https://avatars.githubusercontent.com/u/146967?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredpar","html_url":"https://github.com/jaredpar","followers_url":"https://api.github.com/users/jaredpar/followers","following_url":"https://api.github.com/users/jaredpar/following{/other_user}","gists_url":"https://api.github.com/users/jaredpar/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredpar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredpar/subscriptions","organizations_url":"https://api.github.com/users/jaredpar/orgs","repos_url":"https://api.github.com/users/jaredpar/repos","events_url":"https://api.github.com/users/jaredpar/events{/privacy}","received_events_url":"https://api.github.com/users/jaredpar/received_events","type":"User","site_admin":false},"open_issues":69,"closed_issues":535,"state":"open","created_at":"2015-01-15T20:45:24Z","updated_at":"2015-05-29T21:24:21Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/dotnet/roslyn/pulls/3162/commits","review_comments_url":"https://api.github.com/repos/dotnet/roslyn/pulls/3162/comments","review_comment_url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/3162/comments","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/09c5d7ac20bfee71d6cf415b8dc304c2f38ecfcb","head":{"label":"mavasani:StatefulAnalyzer_Analyzer","ref":"StatefulAnalyzer_Analyzer","sha":"09c5d7ac20bfee71d6cf415b8dc304c2f38ecfcb","user":{"login":"mavasani","id":10605811,"avatar_url":"https://avatars.githubusercontent.com/u/10605811?v=3","gravatar_id":"","url":"https://api.github.com/users/mavasani","html_url":"https://github.com/mavasani","followers_url":"https://api.github.com/users/mavasani/followers","following_url":"https://api.github.com/users/mavasani/following{/other_user}","gists_url":"https://api.github.com/users/mavasani/gists{/gist_id}","starred_url":"https://api.github.com/users/mavasani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mavasani/subscriptions","organizations_url":"https://api.github.com/users/mavasani/orgs","repos_url":"https://api.github.com/users/mavasani/repos","events_url":"https://api.github.com/users/mavasani/events{/privacy}","received_events_url":"https://api.github.com/users/mavasani/received_events","type":"User","site_admin":false},"repo":{"id":30584055,"name":"roslyn","full_name":"mavasani/roslyn","owner":{"login":"mavasani","id":10605811,"avatar_url":"https://avatars.githubusercontent.com/u/10605811?v=3","gravatar_id":"","url":"https://api.github.com/users/mavasani","html_url":"https://github.com/mavasani","followers_url":"https://api.github.com/users/mavasani/followers","following_url":"https://api.github.com/users/mavasani/following{/other_user}","gists_url":"https://api.github.com/users/mavasani/gists{/gist_id}","starred_url":"https://api.github.com/users/mavasani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mavasani/subscriptions","organizations_url":"https://api.github.com/users/mavasani/orgs","repos_url":"https://api.github.com/users/mavasani/repos","events_url":"https://api.github.com/users/mavasani/events{/privacy}","received_events_url":"https://api.github.com/users/mavasani/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mavasani/roslyn","description":"The .NET Compiler Platform (\"Roslyn\") provides open-source C# and Visual Basic compilers with rich code analysis APIs.","fork":true,"url":"https://api.github.com/repos/mavasani/roslyn","forks_url":"https://api.github.com/repos/mavasani/roslyn/forks","keys_url":"https://api.github.com/repos/mavasani/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mavasani/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mavasani/roslyn/teams","hooks_url":"https://api.github.com/repos/mavasani/roslyn/hooks","issue_events_url":"https://api.github.com/repos/mavasani/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/mavasani/roslyn/events","assignees_url":"https://api.github.com/repos/mavasani/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/mavasani/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/mavasani/roslyn/tags","blobs_url":"https://api.github.com/repos/mavasani/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mavasani/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mavasani/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/mavasani/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mavasani/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/mavasani/roslyn/languages","stargazers_url":"https://api.github.com/repos/mavasani/roslyn/stargazers","contributors_url":"https://api.github.com/repos/mavasani/roslyn/contributors","subscribers_url":"https://api.github.com/repos/mavasani/roslyn/subscribers","subscription_url":"https://api.github.com/repos/mavasani/roslyn/subscription","commits_url":"https://api.github.com/repos/mavasani/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/mavasani/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/mavasani/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/mavasani/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/mavasani/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/mavasani/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mavasani/roslyn/merges","archive_url":"https://api.github.com/repos/mavasani/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mavasani/roslyn/downloads","issues_url":"https://api.github.com/repos/mavasani/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/mavasani/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/mavasani/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/mavasani/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mavasani/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/mavasani/roslyn/releases{/id}","created_at":"2015-02-10T09:12:41Z","updated_at":"2015-02-10T09:13:10Z","pushed_at":"2015-05-29T21:05:53Z","git_url":"git://github.com/mavasani/roslyn.git","ssh_url":"git@github.com:mavasani/roslyn.git","clone_url":"https://github.com/mavasani/roslyn.git","svn_url":"https://github.com/mavasani/roslyn","homepage":"","size":77828,"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":"master"}},"base":{"label":"dotnet:stabilization","ref":"stabilization","sha":"6bab425ece7ac20f59558c46411185c9d4352d2c","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":29078997,"name":"roslyn","full_name":"dotnet/roslyn","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/roslyn","description":"The .NET Compiler Platform (\"Roslyn\") provides open-source C# and Visual Basic compilers with rich code analysis APIs.","fork":false,"url":"https://api.github.com/repos/dotnet/roslyn","forks_url":"https://api.github.com/repos/dotnet/roslyn/forks","keys_url":"https://api.github.com/repos/dotnet/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/roslyn/teams","hooks_url":"https://api.github.com/repos/dotnet/roslyn/hooks","issue_events_url":"https://api.github.com/repos/dotnet/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/roslyn/events","assignees_url":"https://api.github.com/repos/dotnet/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/roslyn/tags","blobs_url":"https://api.github.com/repos/dotnet/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/roslyn/languages","stargazers_url":"https://api.github.com/repos/dotnet/roslyn/stargazers","contributors_url":"https://api.github.com/repos/dotnet/roslyn/contributors","subscribers_url":"https://api.github.com/repos/dotnet/roslyn/subscribers","subscription_url":"https://api.github.com/repos/dotnet/roslyn/subscription","commits_url":"https://api.github.com/repos/dotnet/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/roslyn/merges","archive_url":"https://api.github.com/repos/dotnet/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/roslyn/downloads","issues_url":"https://api.github.com/repos/dotnet/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/roslyn/releases{/id}","created_at":"2015-01-11T02:39:03Z","updated_at":"2015-05-29T21:19:19Z","pushed_at":"2015-05-29T21:19:46Z","git_url":"git://github.com/dotnet/roslyn.git","ssh_url":"git@github.com:dotnet/roslyn.git","clone_url":"https://github.com/dotnet/roslyn.git","svn_url":"https://github.com/dotnet/roslyn","homepage":"","size":141597,"stargazers_count":2400,"watchers_count":2400,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":513,"mirror_url":null,"open_issues_count":878,"forks":513,"open_issues":878,"watchers":2400,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/3162"},"html":{"href":"https://github.com/dotnet/roslyn/pull/3162"},"issue":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/3162"},"comments":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/3162/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/3162/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/3162/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/roslyn/statuses/09c5d7ac20bfee71d6cf415b8dc304c2f38ecfcb"}}}}