{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/316446897","pull_request_review_id":278129112,"id":316446897,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMxNjQ0Njg5Nw==","diff_hunk":"@@ -129,6 +131,45 @@ protected override bool ReadOnlyFieldAllowed()\n                 var scope = this.SelectionResult.GetContainingScopeOf<ConstructorDeclarationSyntax>();\n                 return scope == null;\n             }\n+\n+            protected override ITypeSymbol GetSymbolType(SemanticModel semanticModel, ISymbol symbol)\n+            {\n+                var selectionOperation = semanticModel.GetOperation(this.SelectionResult.GetContainingScope());\n+\n+                switch (symbol)\n+                {\n+                    case ILocalSymbol localSymbol when localSymbol.NullableAnnotation == NullableAnnotation.Annotated:\n+                    case IParameterSymbol parameterSymbol when parameterSymbol.NullableAnnotation == NullableAnnotation.Annotated:\n+\n+                        // For local symbols and parameters, we can check what the flow state \n+                        // for refences to the symbols are and determine if we can change \n+                        // the nullability to a less permissive state.\n+                        var references = selectionOperation.DescendantsAndSelf()\n+                            .Where(IsSymbolReferencedByOperation);\n+\n+                        if (AreAllReferencesNotNull(references))\n+                        {\n+                            return base.GetSymbolType(semanticModel, symbol).WithNullability(NullableAnnotation.NotAnnotated);\n+                        }\n+\n+                        return base.GetSymbolType(semanticModel, symbol);\n+\n+                    default:\n+                        return base.GetSymbolType(semanticModel, symbol);\n+                }\n+\n+                bool AreAllReferencesNotNull(IEnumerable<IOperation> references)\n+                => references.All(r => semanticModel.GetTypeInfo(r.Syntax).Nullability.FlowState == NullableFlowState.NotNull);","path":"src/Features/CSharp/Portable/ExtractMethod/CSharpMethodExtractor.Analyzer.cs","position":41,"original_position":41,"commit_id":"4881f5f345f1514ea8da5c4e67fb0c4786e1aee7","original_commit_id":"4881f5f345f1514ea8da5c4e67fb0c4786e1aee7","user":{"login":"jasonmalinowski","id":201340,"node_id":"MDQ6VXNlcjIwMTM0MA==","avatar_url":"https://avatars3.githubusercontent.com/u/201340?v=4","gravatar_id":"","url":"https://api.github.com/users/jasonmalinowski","html_url":"https://github.com/jasonmalinowski","followers_url":"https://api.github.com/users/jasonmalinowski/followers","following_url":"https://api.github.com/users/jasonmalinowski/following{/other_user}","gists_url":"https://api.github.com/users/jasonmalinowski/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonmalinowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonmalinowski/subscriptions","organizations_url":"https://api.github.com/users/jasonmalinowski/orgs","repos_url":"https://api.github.com/users/jasonmalinowski/repos","events_url":"https://api.github.com/users/jasonmalinowski/events{/privacy}","received_events_url":"https://api.github.com/users/jasonmalinowski/received_events","type":"User","site_admin":false},"body":"```suggestion\r\n                => references.All(r => semanticModel.GetTypeInfo(r.Syntax, cancellationToken).Nullability.FlowState == NullableFlowState.NotNull);\r\n```","created_at":"2019-08-21T23:46:55Z","updated_at":"2019-08-21T23:52:43Z","html_url":"https://github.com/dotnet/roslyn/pull/37851#discussion_r316446897","pull_request_url":"https://api.github.com/repos/dotnet/roslyn/pulls/37851","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/316446897"},"html":{"href":"https://github.com/dotnet/roslyn/pull/37851#discussion_r316446897"},"pull_request":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/37851"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/37851","id":305785684,"node_id":"MDExOlB1bGxSZXF1ZXN0MzA1Nzg1Njg0","html_url":"https://github.com/dotnet/roslyn/pull/37851","diff_url":"https://github.com/dotnet/roslyn/pull/37851.diff","patch_url":"https://github.com/dotnet/roslyn/pull/37851.patch","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/37851","number":37851,"state":"open","locked":false,"title":"Add nullability information to extract method","user":{"login":"ryzngard","id":475144,"node_id":"MDQ6VXNlcjQ3NTE0NA==","avatar_url":"https://avatars2.githubusercontent.com/u/475144?v=4","gravatar_id":"","url":"https://api.github.com/users/ryzngard","html_url":"https://github.com/ryzngard","followers_url":"https://api.github.com/users/ryzngard/followers","following_url":"https://api.github.com/users/ryzngard/following{/other_user}","gists_url":"https://api.github.com/users/ryzngard/gists{/gist_id}","starred_url":"https://api.github.com/users/ryzngard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryzngard/subscriptions","organizations_url":"https://api.github.com/users/ryzngard/orgs","repos_url":"https://api.github.com/users/ryzngard/repos","events_url":"https://api.github.com/users/ryzngard/events{/privacy}","received_events_url":"https://api.github.com/users/ryzngard/received_events","type":"User","site_admin":false},"body":"The general premise is to favor non nullable reference types when possible, but we need to use flow analysis to be sure. \r\n\r\n* Use analysis on all parameters to determine if they are ever assigned to null (if a ref parameter) \r\n* Analyze if a parameter is never null in reference locations\r\n* Analyze all returns of a generated method to determine if null is possible\r\n* Add, hopefully, enough comprehensive tests to cover a wide array of possibilities","created_at":"2019-08-08T23:35:32Z","updated_at":"2019-08-21T23:52:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a8c4ceb24f259da946cda53d50ede3010efab05f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":166377917,"node_id":"MDU6TGFiZWwxNjYzNzc5MTc=","url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-IDE","name":"Area-IDE","color":"5319e7","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/roslyn/pulls/37851/commits","review_comments_url":"https://api.github.com/repos/dotnet/roslyn/pulls/37851/comments","review_comment_url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/37851/comments","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/4881f5f345f1514ea8da5c4e67fb0c4786e1aee7","head":{"label":"ryzngard:issue/extract_method_nullability","ref":"issue/extract_method_nullability","sha":"4881f5f345f1514ea8da5c4e67fb0c4786e1aee7","user":{"login":"ryzngard","id":475144,"node_id":"MDQ6VXNlcjQ3NTE0NA==","avatar_url":"https://avatars2.githubusercontent.com/u/475144?v=4","gravatar_id":"","url":"https://api.github.com/users/ryzngard","html_url":"https://github.com/ryzngard","followers_url":"https://api.github.com/users/ryzngard/followers","following_url":"https://api.github.com/users/ryzngard/following{/other_user}","gists_url":"https://api.github.com/users/ryzngard/gists{/gist_id}","starred_url":"https://api.github.com/users/ryzngard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryzngard/subscriptions","organizations_url":"https://api.github.com/users/ryzngard/orgs","repos_url":"https://api.github.com/users/ryzngard/repos","events_url":"https://api.github.com/users/ryzngard/events{/privacy}","received_events_url":"https://api.github.com/users/ryzngard/received_events","type":"User","site_admin":false},"repo":{"id":150510253,"node_id":"MDEwOlJlcG9zaXRvcnkxNTA1MTAyNTM=","name":"roslyn","full_name":"ryzngard/roslyn","private":false,"owner":{"login":"ryzngard","id":475144,"node_id":"MDQ6VXNlcjQ3NTE0NA==","avatar_url":"https://avatars2.githubusercontent.com/u/475144?v=4","gravatar_id":"","url":"https://api.github.com/users/ryzngard","html_url":"https://github.com/ryzngard","followers_url":"https://api.github.com/users/ryzngard/followers","following_url":"https://api.github.com/users/ryzngard/following{/other_user}","gists_url":"https://api.github.com/users/ryzngard/gists{/gist_id}","starred_url":"https://api.github.com/users/ryzngard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryzngard/subscriptions","organizations_url":"https://api.github.com/users/ryzngard/orgs","repos_url":"https://api.github.com/users/ryzngard/repos","events_url":"https://api.github.com/users/ryzngard/events{/privacy}","received_events_url":"https://api.github.com/users/ryzngard/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ryzngard/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/ryzngard/roslyn","forks_url":"https://api.github.com/repos/ryzngard/roslyn/forks","keys_url":"https://api.github.com/repos/ryzngard/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ryzngard/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ryzngard/roslyn/teams","hooks_url":"https://api.github.com/repos/ryzngard/roslyn/hooks","issue_events_url":"https://api.github.com/repos/ryzngard/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/ryzngard/roslyn/events","assignees_url":"https://api.github.com/repos/ryzngard/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/ryzngard/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/ryzngard/roslyn/tags","blobs_url":"https://api.github.com/repos/ryzngard/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ryzngard/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ryzngard/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/ryzngard/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ryzngard/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/ryzngard/roslyn/languages","stargazers_url":"https://api.github.com/repos/ryzngard/roslyn/stargazers","contributors_url":"https://api.github.com/repos/ryzngard/roslyn/contributors","subscribers_url":"https://api.github.com/repos/ryzngard/roslyn/subscribers","subscription_url":"https://api.github.com/repos/ryzngard/roslyn/subscription","commits_url":"https://api.github.com/repos/ryzngard/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/ryzngard/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/ryzngard/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/ryzngard/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/ryzngard/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/ryzngard/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ryzngard/roslyn/merges","archive_url":"https://api.github.com/repos/ryzngard/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ryzngard/roslyn/downloads","issues_url":"https://api.github.com/repos/ryzngard/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/ryzngard/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/ryzngard/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/ryzngard/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ryzngard/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/ryzngard/roslyn/releases{/id}","deployments_url":"https://api.github.com/repos/ryzngard/roslyn/deployments","created_at":"2018-09-27T01:19:34Z","updated_at":"2019-08-20T21:17:51Z","pushed_at":"2019-08-21T19:57:16Z","git_url":"git://github.com/ryzngard/roslyn.git","ssh_url":"git@github.com:ryzngard/roslyn.git","clone_url":"https://github.com/ryzngard/roslyn.git","svn_url":"https://github.com/ryzngard/roslyn","homepage":"","size":665102,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"5551fad9651b91dcc64a965cfd93e1da4f386273","user":{"login":"dotnet","id":9141961,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNDE5NjE=","avatar_url":"https://avatars0.githubusercontent.com/u/9141961?v=4","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,"node_id":"MDEwOlJlcG9zaXRvcnkyOTA3ODk5Nw==","name":"roslyn","full_name":"dotnet/roslyn","private":false,"owner":{"login":"dotnet","id":9141961,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNDE5NjE=","avatar_url":"https://avatars0.githubusercontent.com/u/9141961?v=4","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},"html_url":"https://github.com/dotnet/roslyn","description":"The Roslyn .NET compiler provides C# and Visual Basic languages 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}","deployments_url":"https://api.github.com/repos/dotnet/roslyn/deployments","created_at":"2015-01-11T02:39:03Z","updated_at":"2019-08-21T23:34:58Z","pushed_at":"2019-08-21T23:46:38Z","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":"https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/","size":709037,"stargazers_count":11763,"watchers_count":11763,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2723,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":6356,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":2723,"open_issues":6356,"watchers":11763,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/37851"},"html":{"href":"https://github.com/dotnet/roslyn/pull/37851"},"issue":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/37851"},"comments":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/37851/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/37851/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/37851/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/roslyn/statuses/4881f5f345f1514ea8da5c4e67fb0c4786e1aee7"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jasonmalinowski"}}