Roslyn: C# 8 Intellisense "Introduce 'using' statement" should use **simple** using statement

Created on 29 Jun 2019  路  3Comments  路  Source: dotnet/roslyn

VSF_TYPE_MARKDOWNWhen we get the warning "Disposable object created by '' is never disposed", C# 8 intellisense should us the simple using statement ( e.g. using var s = new MemoryStream(); ) instead of the using block statement.

_This issue has been moved from https://developercommunity.visualstudio.com/content/idea/619119/c-8-intellisense-introduce-using-statement-should.html
VSTS ticketId: 936507_
_These are the original issue comments:_

Jane Wu [MSFT] on 6/25/2019, 01:31 AM (3 days ago):

Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. We鈥檒l provide an update once the issue has been triaged by the product team.


Area-IDE Developer Community Feature Request help wanted

Most helpful comment

This refactoring should use simple using statements if and only if the scope for the inserted block ends at the end of the enclosing block. In other words, it should use the simple using statement only when the semantics of the simple using statement are the same as the semantics for the block this refactoring inserts today. We have a refactoring to assist in converting full using statements to the simple form; the analysis from that refactoring could be reused for this feature.

All 3 comments

This refactoring should use simple using statements if and only if the scope for the inserted block ends at the end of the enclosing block. In other words, it should use the simple using statement only when the semantics of the simple using statement are the same as the semantics for the block this refactoring inserts today. We have a refactoring to assist in converting full using statements to the simple form; the analysis from that refactoring could be reused for this feature.

In C# spec lingo, the one we've always had is a 'using statement' and the new thing is a 'using declaration.'

Duplicate of #33699

Was this page helpful?
0 / 5 - 0 ratings