{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/2331","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/2331/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/2331/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/2331/events","html_url":"https://github.com/dotnet/roslyn/issues/2331","id":71661929,"number":2331,"title":"Proposal: multiple assignments per using statement","user":{"login":"Arithmomaniac","id":654897,"avatar_url":"https://avatars.githubusercontent.com/u/654897?v=3","gravatar_id":"","url":"https://api.github.com/users/Arithmomaniac","html_url":"https://github.com/Arithmomaniac","followers_url":"https://api.github.com/users/Arithmomaniac/followers","following_url":"https://api.github.com/users/Arithmomaniac/following{/other_user}","gists_url":"https://api.github.com/users/Arithmomaniac/gists{/gist_id}","starred_url":"https://api.github.com/users/Arithmomaniac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Arithmomaniac/subscriptions","organizations_url":"https://api.github.com/users/Arithmomaniac/orgs","repos_url":"https://api.github.com/users/Arithmomaniac/repos","events_url":"https://api.github.com/users/Arithmomaniac/events{/privacy}","received_events_url":"https://api.github.com/users/Arithmomaniac/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Language%20Design","name":"Area-Language Design","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-04-28T18:11:02Z","updated_at":"2015-04-29T17:21:07Z","closed_at":null,"body":"### Motivating Example\r\n\r\nTo use `SqlCommand` as an example, I often have code that ends up looking like the following:\r\n\r\n\tusing (var connection = new SqlConnection(connectionString))\r\n\t{\r\n\t\tusing (var command = new SqlCommand(commandText, connection))\r\n\t\t{\r\n\t\t\tDoSomething(command);\r\n\t\t}\r\n\t}\r\n\r\nTo cut down on the code clutter, I sometimes do this instead:\r\n\r\n\tusing (var connection = new SqlConnection(connectionString))\r\n\tusing (var command = new SqlCommand(commandText, connection))\r\n\t{\r\n\t\tDoSomething(command);\r\n\t}\r\n\r\nBut like any multi-line unbracketed scope, this is prone to breakage.\r\n\r\n### Proposal\r\n\r\n- Multiple assignments can be made inside of a `using` block. \r\n- Each assignment would have to follow the current syntax, and each one would have to be separated by a semicolon.\r\n- This is compiled into a set of nested `using` blocks, with the left-most assignment being of outermost scope.\r\n\r\n### Example Usage\r\nThis would be equivalent to the motivating example:\r\n\r\n    using (var connection = new SqlConnection(connectionString); \r\n      var command = new SqlCommand(commandText, connection))\r\n\t{\r\n\t\tDoSomething(command);\r\n\t}"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/97510220","html_url":"https://github.com/dotnet/roslyn/issues/2331#issuecomment-97510220","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/2331","id":97510220,"user":{"login":"GSPP","id":12032350,"avatar_url":"https://avatars.githubusercontent.com/u/12032350?v=3","gravatar_id":"","url":"https://api.github.com/users/GSPP","html_url":"https://github.com/GSPP","followers_url":"https://api.github.com/users/GSPP/followers","following_url":"https://api.github.com/users/GSPP/following{/other_user}","gists_url":"https://api.github.com/users/GSPP/gists{/gist_id}","starred_url":"https://api.github.com/users/GSPP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GSPP/subscriptions","organizations_url":"https://api.github.com/users/GSPP/orgs","repos_url":"https://api.github.com/users/GSPP/repos","events_url":"https://api.github.com/users/GSPP/events{/privacy}","received_events_url":"https://api.github.com/users/GSPP/received_events","type":"User","site_admin":false},"created_at":"2015-04-29T17:21:07Z","updated_at":"2015-04-29T17:21:07Z","body":"The existing pattern of multiple usings without braces properly solves this issue. All syntax formatting tools support it. It looks like. This proposal does not carry its weight. In fact I consider the new syntax to be worse."}}