{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/219684692","pull_request_review_id":157925067,"id":219684692,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxOTY4NDY5Mg==","diff_hunk":"@@ -0,0 +1,72 @@\n+﻿using System;\n+using System.Composition;\n+using System.Linq;\n+using System.Threading;\n+using System.Threading.Tasks;\n+using Microsoft.CodeAnalysis.CodeRefactorings;\n+using Microsoft.CodeAnalysis.CSharp.Syntax;\n+using Microsoft.CodeAnalysis.Editing;\n+using Microsoft.CodeAnalysis.IntroduceUsingStatement;\n+using Microsoft.CodeAnalysis.LanguageServices;\n+using Microsoft.CodeAnalysis.Shared.Extensions;\n+using Microsoft.CodeAnalysis.Utilities;\n+\n+namespace Microsoft.CodeAnalysis.CSharp.IntroduceUsingStatement\n+{\n+    [ExtensionOrder(Before = PredefinedCodeRefactoringProviderNames.IntroduceVariable)]\n+    [ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = PredefinedCodeRefactoringProviderNames.IntroduceUsingStatement), Shared]\n+    internal sealed class CSharpIntroduceUsingStatementCodeRefactoringProvider\n+        : AbstractIntroduceUsingStatementCodeRefactoringProvider<LocalDeclarationStatementSyntax>\n+    {\n+        protected override async Task<Document> IntroduceUsingStatementAsync(\n+            Document document,\n+            LocalDeclarationStatementSyntax declarationSyntax,\n+            ILocalSymbol localVariable,\n+            CancellationToken cancellationToken)\n+        {\n+            var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);\n+            var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);\n+\n+            if (!(declarationSyntax.Parent is BlockSyntax parent))\n+            {\n+                throw new NotImplementedException();\n+            }\n+\n+            var lastStatement = (StatementSyntax)FindSiblingContainingLastUsage(\n+                declarationSyntax,\n+                localVariable,\n+                semanticModel,\n+                document.GetLanguageService<ISyntaxFactsService>(),\n+                cancellationToken);\n+\n+            var declarationSyntaxIndex = parent.Statements.IndexOf(declarationSyntax);\n+            var replaceCount = 1;\n+            var block = SyntaxFactory.Block();\n+\n+            if (lastStatement != null)\n+            {\n+                var lastStatementIndex = parent.Statements.IndexOf(lastStatement, declarationSyntaxIndex + 1);\n+\n+                block = SyntaxFactory.Block(parent.Statements\n+                    .Take(lastStatementIndex + 1)\n+                    .Skip(declarationSyntaxIndex + 1));\n+\n+                replaceCount += lastStatementIndex - declarationSyntaxIndex;\n+            }\n+\n+            var usingStatementSyntax =\n+                SyntaxFactory.UsingStatement(\n+                    declaration: declarationSyntax.Declaration,\n+                    expression: null, // Declaration already has equals token and expression\n+                    statement: block);\n+\n+            var newParent = parent\n+                .WithStatements(parent.Statements\n+                    .ReplaceRange(declarationSyntaxIndex, replaceCount, new[] { usingStatementSyntax }));\n+\n+            return document\n+                .WithSyntaxRoot(root\n+                    .ReplaceNode(parent, newParent));","path":"src/Features/CSharp/Portable/IntroduceUsingStatement/CSharpIntroduceUsingStatementCodeRefactoringProvider.cs","position":69,"original_position":69,"commit_id":"08c88b5feedb9dc35a4945a1e03e69a08d476e65","original_commit_id":"08c88b5feedb9dc35a4945a1e03e69a08d476e65","user":{"login":"CyrusNajmabadi","id":4564579,"node_id":"MDQ6VXNlcjQ1NjQ1Nzk=","avatar_url":"https://avatars3.githubusercontent.com/u/4564579?v=4","gravatar_id":"","url":"https://api.github.com/users/CyrusNajmabadi","html_url":"https://github.com/CyrusNajmabadi","followers_url":"https://api.github.com/users/CyrusNajmabadi/followers","following_url":"https://api.github.com/users/CyrusNajmabadi/following{/other_user}","gists_url":"https://api.github.com/users/CyrusNajmabadi/gists{/gist_id}","starred_url":"https://api.github.com/users/CyrusNajmabadi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CyrusNajmabadi/subscriptions","organizations_url":"https://api.github.com/users/CyrusNajmabadi/orgs","repos_url":"https://api.github.com/users/CyrusNajmabadi/repos","events_url":"https://api.github.com/users/CyrusNajmabadi/events{/privacy}","received_events_url":"https://api.github.com/users/CyrusNajmabadi/received_events","type":"User","site_admin":false},"body":"it feels like most of this logic could move down.  the overall shape would be nearly teh same for VB.  Several things could be figured out commonly with IOperatoin.  And there woudl only need to be a few points of very specialized work for C#/VB.","created_at":"2018-09-22T23:51:39Z","updated_at":"2018-09-22T23:51:39Z","html_url":"https://github.com/dotnet/roslyn/pull/30106#discussion_r219684692","pull_request_url":"https://api.github.com/repos/dotnet/roslyn/pulls/30106","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/219684692"},"html":{"href":"https://github.com/dotnet/roslyn/pull/30106#discussion_r219684692"},"pull_request":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/30106"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/30106","id":217483890,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE3NDgzODkw","html_url":"https://github.com/dotnet/roslyn/pull/30106","diff_url":"https://github.com/dotnet/roslyn/pull/30106.diff","patch_url":"https://github.com/dotnet/roslyn/pull/30106.patch","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/30106","number":30106,"state":"open","locked":false,"title":"[wip] Introduce using statement","user":{"login":"jnm2","id":8040367,"node_id":"MDQ6VXNlcjgwNDAzNjc=","avatar_url":"https://avatars2.githubusercontent.com/u/8040367?v=4","gravatar_id":"","url":"https://api.github.com/users/jnm2","html_url":"https://github.com/jnm2","followers_url":"https://api.github.com/users/jnm2/followers","following_url":"https://api.github.com/users/jnm2/following{/other_user}","gists_url":"https://api.github.com/users/jnm2/gists{/gist_id}","starred_url":"https://api.github.com/users/jnm2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnm2/subscriptions","organizations_url":"https://api.github.com/users/jnm2/orgs","repos_url":"https://api.github.com/users/jnm2/repos","events_url":"https://api.github.com/users/jnm2/events{/privacy}","received_events_url":"https://api.github.com/users/jnm2/received_events","type":"User","site_admin":false},"body":"/cc @CyrusNajmabadi ","created_at":"2018-09-22T23:34:21Z","updated_at":"2018-09-22T23:51:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1cf58fd2d788054618b32bcba51236fe11392946","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[{"name":"roslyn-ide","id":1781706,"node_id":"MDQ6VGVhbTE3ODE3MDY=","slug":"roslyn-ide","description":"Roslyn IDE Team","privacy":"closed","url":"https://api.github.com/teams/1781706","members_url":"https://api.github.com/teams/1781706/members{/member}","repositories_url":"https://api.github.com/teams/1781706/repos","permission":"pull"},{"name":"roslyn-compiler","id":1803172,"node_id":"MDQ6VGVhbTE4MDMxNzI=","slug":"roslyn-compiler","description":"Roslyn Compiler Team","privacy":"closed","url":"https://api.github.com/teams/1803172","members_url":"https://api.github.com/teams/1803172/members{/member}","repositories_url":"https://api.github.com/teams/1803172/repos","permission":"pull"}],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/roslyn/pulls/30106/commits","review_comments_url":"https://api.github.com/repos/dotnet/roslyn/pulls/30106/comments","review_comment_url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/30106/comments","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/08c88b5feedb9dc35a4945a1e03e69a08d476e65","head":{"label":"jnm2:introduce_using_statement","ref":"introduce_using_statement","sha":"08c88b5feedb9dc35a4945a1e03e69a08d476e65","user":{"login":"jnm2","id":8040367,"node_id":"MDQ6VXNlcjgwNDAzNjc=","avatar_url":"https://avatars2.githubusercontent.com/u/8040367?v=4","gravatar_id":"","url":"https://api.github.com/users/jnm2","html_url":"https://github.com/jnm2","followers_url":"https://api.github.com/users/jnm2/followers","following_url":"https://api.github.com/users/jnm2/following{/other_user}","gists_url":"https://api.github.com/users/jnm2/gists{/gist_id}","starred_url":"https://api.github.com/users/jnm2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnm2/subscriptions","organizations_url":"https://api.github.com/users/jnm2/orgs","repos_url":"https://api.github.com/users/jnm2/repos","events_url":"https://api.github.com/users/jnm2/events{/privacy}","received_events_url":"https://api.github.com/users/jnm2/received_events","type":"User","site_admin":false},"repo":{"id":92682284,"node_id":"MDEwOlJlcG9zaXRvcnk5MjY4MjI4NA==","name":"roslyn","full_name":"jnm2/roslyn","private":false,"owner":{"login":"jnm2","id":8040367,"node_id":"MDQ6VXNlcjgwNDAzNjc=","avatar_url":"https://avatars2.githubusercontent.com/u/8040367?v=4","gravatar_id":"","url":"https://api.github.com/users/jnm2","html_url":"https://github.com/jnm2","followers_url":"https://api.github.com/users/jnm2/followers","following_url":"https://api.github.com/users/jnm2/following{/other_user}","gists_url":"https://api.github.com/users/jnm2/gists{/gist_id}","starred_url":"https://api.github.com/users/jnm2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnm2/subscriptions","organizations_url":"https://api.github.com/users/jnm2/orgs","repos_url":"https://api.github.com/users/jnm2/repos","events_url":"https://api.github.com/users/jnm2/events{/privacy}","received_events_url":"https://api.github.com/users/jnm2/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jnm2/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/jnm2/roslyn","forks_url":"https://api.github.com/repos/jnm2/roslyn/forks","keys_url":"https://api.github.com/repos/jnm2/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jnm2/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jnm2/roslyn/teams","hooks_url":"https://api.github.com/repos/jnm2/roslyn/hooks","issue_events_url":"https://api.github.com/repos/jnm2/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/jnm2/roslyn/events","assignees_url":"https://api.github.com/repos/jnm2/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/jnm2/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/jnm2/roslyn/tags","blobs_url":"https://api.github.com/repos/jnm2/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jnm2/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jnm2/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/jnm2/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jnm2/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/jnm2/roslyn/languages","stargazers_url":"https://api.github.com/repos/jnm2/roslyn/stargazers","contributors_url":"https://api.github.com/repos/jnm2/roslyn/contributors","subscribers_url":"https://api.github.com/repos/jnm2/roslyn/subscribers","subscription_url":"https://api.github.com/repos/jnm2/roslyn/subscription","commits_url":"https://api.github.com/repos/jnm2/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/jnm2/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/jnm2/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/jnm2/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/jnm2/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/jnm2/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jnm2/roslyn/merges","archive_url":"https://api.github.com/repos/jnm2/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jnm2/roslyn/downloads","issues_url":"https://api.github.com/repos/jnm2/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/jnm2/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/jnm2/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/jnm2/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jnm2/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/jnm2/roslyn/releases{/id}","deployments_url":"https://api.github.com/repos/jnm2/roslyn/deployments","created_at":"2017-05-28T19:26:35Z","updated_at":"2018-08-14T21:00:34Z","pushed_at":"2018-09-22T23:36:16Z","git_url":"git://github.com/jnm2/roslyn.git","ssh_url":"git@github.com:jnm2/roslyn.git","clone_url":"https://github.com/jnm2/roslyn.git","svn_url":"https://github.com/jnm2/roslyn","homepage":"","size":375552,"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,"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":"redundant_generated_ctor_call"}},"base":{"label":"dotnet:master","ref":"master","sha":"1060b7c1bfabc92ee01738bff8afcb33daf9985c","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 .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}","deployments_url":"https://api.github.com/repos/dotnet/roslyn/deployments","created_at":"2015-01-11T02:39:03Z","updated_at":"2018-09-22T13:03:59Z","pushed_at":"2018-09-22T23:36:20Z","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":453336,"stargazers_count":9869,"watchers_count":9869,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2362,"mirror_url":null,"archived":false,"open_issues_count":5225,"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":2362,"open_issues":5225,"watchers":9869,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/30106"},"html":{"href":"https://github.com/dotnet/roslyn/pull/30106"},"issue":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/30106"},"comments":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/30106/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/30106/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/30106/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/roslyn/statuses/08c88b5feedb9dc35a4945a1e03e69a08d476e65"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"CyrusNajmabadi"}}