{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/roslyn-analyzers/pulls/comments/59935335","id":59935335,"diff_hunk":"@@ -27,42 +30,221 @@ public abstract class CallGCSuppressFinalizeCorrectlyAnalyzer : DiagnosticAnalyz\n                                                                              s_localizableMessageNotCalledWithFinalizer,\n                                                                              DiagnosticCategory.Performance,\n                                                                              DiagnosticSeverity.Warning,\n-                                                                             isEnabledByDefault: false,\n+                                                                             isEnabledByDefault: true,\n                                                                              description: s_localizableDescription,\n-                                                                             helpLinkUri: null,     // TODO: add MSDN url\n+                                                                             helpLinkUri: \"https://msdn.microsoft.com/en-US/library/ms182269.aspx\",\n                                                                              customTags: WellKnownDiagnosticTags.Telemetry);\n         internal static DiagnosticDescriptor NotCalledRule = new DiagnosticDescriptor(RuleId,\n                                                                              s_localizableTitle,\n                                                                              s_localizableMessageNotCalled,\n                                                                              DiagnosticCategory.Performance,\n                                                                              DiagnosticSeverity.Warning,\n-                                                                             isEnabledByDefault: false,\n+                                                                             isEnabledByDefault: true,\n                                                                              description: s_localizableDescription,\n-                                                                             helpLinkUri: null,     // TODO: add MSDN url\n+                                                                             helpLinkUri: \"https://msdn.microsoft.com/en-US/library/ms182269.aspx\",\n                                                                              customTags: WellKnownDiagnosticTags.Telemetry);\n         internal static DiagnosticDescriptor NotPassedThisRule = new DiagnosticDescriptor(RuleId,\n                                                                              s_localizableTitle,\n                                                                              s_localizableMessageNotPassedThis,\n                                                                              DiagnosticCategory.Performance,\n                                                                              DiagnosticSeverity.Warning,\n-                                                                             isEnabledByDefault: false,\n+                                                                             isEnabledByDefault: true,\n                                                                              description: s_localizableDescription,\n-                                                                             helpLinkUri: null,     // TODO: add MSDN url\n+                                                                             helpLinkUri: \"https://msdn.microsoft.com/en-US/library/ms182269.aspx\",\n                                                                              customTags: WellKnownDiagnosticTags.Telemetry);\n         internal static DiagnosticDescriptor OutsideDisposeRule = new DiagnosticDescriptor(RuleId,\n                                                                              s_localizableTitle,\n                                                                              s_localizableMessageOutsideDispose,\n                                                                              DiagnosticCategory.Performance,\n                                                                              DiagnosticSeverity.Warning,\n-                                                                             isEnabledByDefault: false,\n+                                                                             isEnabledByDefault: true,\n                                                                              description: s_localizableDescription,\n-                                                                             helpLinkUri: null,     // TODO: add MSDN url\n+                                                                             helpLinkUri: \"https://msdn.microsoft.com/en-US/library/ms182269.aspx\",\n                                                                              customTags: WellKnownDiagnosticTags.Telemetry);\n \n         public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(NotCalledWithFinalizerRule, NotCalledRule, NotPassedThisRule, OutsideDisposeRule);\n \n         public override void Initialize(AnalysisContext analysisContext)\n         {\n+            analysisContext.RegisterCompilationStartAction(compilationContext =>\n+            {\n+                var gcSuppressFinalizeMethodSymbol = compilationContext.Compilation\n+                                                        .GetTypeByMetadataName(\"System.GC\")\n+                                                        .GetMembers(\"SuppressFinalize\")\n+                                                        .OfType<IMethodSymbol>()\n+                                                        .SingleOrDefault();\n+\n+                if (gcSuppressFinalizeMethodSymbol == null)\n+                {\n+                    return;\n+                }\n+\n+                compilationContext.RegisterOperationBlockStartAction(operationBlockContext =>\n+                {\n+                    if (operationBlockContext.OwningSymbol.Kind != SymbolKind.Method)\n+                    {\n+                        return;\n+                    }\n+\n+                    var methodSymbol = (IMethodSymbol)operationBlockContext.OwningSymbol;\n+                    if (methodSymbol.IsExtern || methodSymbol.IsAbstract)\n+                    {\n+                        return;\n+                    }\n+\n+                    var analyzer = new SuppressFinalizeAnalyzer(methodSymbol, gcSuppressFinalizeMethodSymbol, compilationContext.Compilation);\n+\n+                    operationBlockContext.RegisterOperationAction(analyzer.Analyze, OperationKind.InvocationExpression);\n+                    operationBlockContext.RegisterOperationBlockEndAction(analyzer.OperationBlockEndAction);\n+                });\n+            });\n+\n+        }\n+\n+        private class SuppressFinalizeAnalyzer\n+        {\n+            private enum SuppressFinalizeUsage\n+            {\n+                CanCall,\n+                MustCall,\n+                MustNotCall\n+            }\n+\n+            private bool _suppressFinalizeCalled = false;\n+\n+            private readonly Compilation _compilation;\n+            private readonly IMethodSymbol _containingMethodSymbol;\n+            private readonly IMethodSymbol _gcSuppressFinalizeMethodSymbol;\n+\n+            private SemanticModel _semanticModel;\n+            private IInvocationExpression _invocationExpression;\n+\n+            public SuppressFinalizeAnalyzer(IMethodSymbol methodSymbol, IMethodSymbol gcSuppressFinalizeMethodSymbol, Compilation compilation)\n+            {\n+                this._compilation = compilation;\n+                this._containingMethodSymbol = methodSymbol;\n+                this._gcSuppressFinalizeMethodSymbol = gcSuppressFinalizeMethodSymbol;\n+            }\n+\n+            public void Analyze(OperationAnalysisContext analysisContext)\n+            {\n+                _invocationExpression = (IInvocationExpression)analysisContext.Operation;","path":"src/System.Runtime.Analyzers/Core/CallGCSuppressFinalizeCorrectly.cs","position":132,"original_position":132,"commit_id":"b603049e4d012e3d20dab34f5b1d9ebe6bcfa9ac","original_commit_id":"b603049e4d012e3d20dab34f5b1d9ebe6bcfa9ac","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":"You can invoke GetAllowedSuppressFinalizeUsage in the constructor of SuppressFinalizeAnalyzer and store the result onto a readonly field.","created_at":"2016-04-15T20:21:17Z","updated_at":"2016-04-15T20:21:17Z","html_url":"https://github.com/dotnet/roslyn-analyzers/pull/929#discussion_r59935335","pull_request_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/pulls/929","_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn-analyzers/pulls/comments/59935335"},"html":{"href":"https://github.com/dotnet/roslyn-analyzers/pull/929#discussion_r59935335"},"pull_request":{"href":"https://api.github.com/repos/dotnet/roslyn-analyzers/pulls/929"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/roslyn-analyzers/pulls/929","id":66683058,"html_url":"https://github.com/dotnet/roslyn-analyzers/pull/929","diff_url":"https://github.com/dotnet/roslyn-analyzers/pull/929.diff","patch_url":"https://github.com/dotnet/roslyn-analyzers/pull/929.patch","issue_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/issues/929","number":929,"state":"open","locked":false,"title":"Implement CA1816 Call GC.SuppressFinalize correctly rule.","user":{"login":"balajikris","id":4213867,"avatar_url":"https://avatars.githubusercontent.com/u/4213867?v=3","gravatar_id":"","url":"https://api.github.com/users/balajikris","html_url":"https://github.com/balajikris","followers_url":"https://api.github.com/users/balajikris/followers","following_url":"https://api.github.com/users/balajikris/following{/other_user}","gists_url":"https://api.github.com/users/balajikris/gists{/gist_id}","starred_url":"https://api.github.com/users/balajikris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balajikris/subscriptions","organizations_url":"https://api.github.com/users/balajikris/orgs","repos_url":"https://api.github.com/users/balajikris/repos","events_url":"https://api.github.com/users/balajikris/events{/privacy}","received_events_url":"https://api.github.com/users/balajikris/received_events","type":"User","site_admin":false},"body":"This implementation is fully backwards compatible with existing FxCop implementation of the rule.\r\nPlus, unit tests for C#. Unit tests for VB is coming in the next commit, meanwhile feel free to review the changes.","created_at":"2016-04-15T18:15:13Z","updated_at":"2016-04-15T20:21:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2bd9bcb9577ef0b521a96c627ab325ed1f2a8af4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/pulls/929/commits","review_comments_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/pulls/929/comments","review_comment_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/issues/929/comments","statuses_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/statuses/b603049e4d012e3d20dab34f5b1d9ebe6bcfa9ac","head":{"label":"balajikris:CA1816","ref":"CA1816","sha":"b603049e4d012e3d20dab34f5b1d9ebe6bcfa9ac","user":{"login":"balajikris","id":4213867,"avatar_url":"https://avatars.githubusercontent.com/u/4213867?v=3","gravatar_id":"","url":"https://api.github.com/users/balajikris","html_url":"https://github.com/balajikris","followers_url":"https://api.github.com/users/balajikris/followers","following_url":"https://api.github.com/users/balajikris/following{/other_user}","gists_url":"https://api.github.com/users/balajikris/gists{/gist_id}","starred_url":"https://api.github.com/users/balajikris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balajikris/subscriptions","organizations_url":"https://api.github.com/users/balajikris/orgs","repos_url":"https://api.github.com/users/balajikris/repos","events_url":"https://api.github.com/users/balajikris/events{/privacy}","received_events_url":"https://api.github.com/users/balajikris/received_events","type":"User","site_admin":false},"repo":{"id":47570573,"name":"roslyn-analyzers","full_name":"balajikris/roslyn-analyzers","owner":{"login":"balajikris","id":4213867,"avatar_url":"https://avatars.githubusercontent.com/u/4213867?v=3","gravatar_id":"","url":"https://api.github.com/users/balajikris","html_url":"https://github.com/balajikris","followers_url":"https://api.github.com/users/balajikris/followers","following_url":"https://api.github.com/users/balajikris/following{/other_user}","gists_url":"https://api.github.com/users/balajikris/gists{/gist_id}","starred_url":"https://api.github.com/users/balajikris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balajikris/subscriptions","organizations_url":"https://api.github.com/users/balajikris/orgs","repos_url":"https://api.github.com/users/balajikris/repos","events_url":"https://api.github.com/users/balajikris/events{/privacy}","received_events_url":"https://api.github.com/users/balajikris/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/balajikris/roslyn-analyzers","description":"","fork":true,"url":"https://api.github.com/repos/balajikris/roslyn-analyzers","forks_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/forks","keys_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/teams","hooks_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/hooks","issue_events_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/issues/events{/number}","events_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/events","assignees_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/assignees{/user}","branches_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/branches{/branch}","tags_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/tags","blobs_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/git/refs{/sha}","trees_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/statuses/{sha}","languages_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/languages","stargazers_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/stargazers","contributors_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/contributors","subscribers_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/subscribers","subscription_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/subscription","commits_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/commits{/sha}","git_commits_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/git/commits{/sha}","comments_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/comments{/number}","issue_comment_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/issues/comments{/number}","contents_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/contents/{+path}","compare_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/merges","archive_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/downloads","issues_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/issues{/number}","pulls_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/pulls{/number}","milestones_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/milestones{/number}","notifications_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/labels{/name}","releases_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/releases{/id}","deployments_url":"https://api.github.com/repos/balajikris/roslyn-analyzers/deployments","created_at":"2015-12-07T18:18:21Z","updated_at":"2015-12-07T18:18:25Z","pushed_at":"2016-04-15T20:14:00Z","git_url":"git://github.com/balajikris/roslyn-analyzers.git","ssh_url":"git@github.com:balajikris/roslyn-analyzers.git","clone_url":"https://github.com/balajikris/roslyn-analyzers.git","svn_url":"https://github.com/balajikris/roslyn-analyzers","homepage":null,"size":6945,"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:master","ref":"master","sha":"9515d816e34f56ef9441d94bd62d7a70ebd4d982","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":36946704,"name":"roslyn-analyzers","full_name":"dotnet/roslyn-analyzers","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-analyzers","description":"","fork":false,"url":"https://api.github.com/repos/dotnet/roslyn-analyzers","forks_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/forks","keys_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/teams","hooks_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/hooks","issue_events_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/events","assignees_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/tags","blobs_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/languages","stargazers_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/stargazers","contributors_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/contributors","subscribers_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/subscribers","subscription_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/subscription","commits_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/merges","archive_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/downloads","issues_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/roslyn-analyzers/deployments","created_at":"2015-06-05T17:48:07Z","updated_at":"2016-04-14T18:20:40Z","pushed_at":"2016-04-15T20:14:01Z","git_url":"git://github.com/dotnet/roslyn-analyzers.git","ssh_url":"git@github.com:dotnet/roslyn-analyzers.git","clone_url":"https://github.com/dotnet/roslyn-analyzers.git","svn_url":"https://github.com/dotnet/roslyn-analyzers","homepage":null,"size":8903,"stargazers_count":97,"watchers_count":97,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":75,"mirror_url":null,"open_issues_count":161,"forks":75,"open_issues":161,"watchers":97,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn-analyzers/pulls/929"},"html":{"href":"https://github.com/dotnet/roslyn-analyzers/pull/929"},"issue":{"href":"https://api.github.com/repos/dotnet/roslyn-analyzers/issues/929"},"comments":{"href":"https://api.github.com/repos/dotnet/roslyn-analyzers/issues/929/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/roslyn-analyzers/pulls/929/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/roslyn-analyzers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/roslyn-analyzers/pulls/929/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/roslyn-analyzers/statuses/b603049e4d012e3d20dab34f5b1d9ebe6bcfa9ac"}}}}