Repro steps:
0. Set your Local declaration style in Programming Style to Use implicit.
- Create a new C# Console App (.NET Framework) in Visual Studio 2017. (We'll call it UsingImplicit.)
- Replace the code in the Program class with the following:
C#using System;
namespace UsingImplicit
{
class Program
{
class Whatever : IDisposable
{
public void Dispose() => throw new NotImplementedException();
}
static void Main(string[] args)
{
new Whatever();
}
}
}
- Put your cursor on Whatever in the Main method.
- Activate the Introduce Using Statement refactoring.
Expected:
The code is refactored to:
C#using (var whatever = new Whatever())
{
}
Actual:
The code is refactored to:
C#using (Whatever whatever = new Whatever())
{
}
Thank you for the code snippets. I have reproduced the problem on my side. I am absolutely agree that the "Introduce Using Statement" feature should correctly process the "Local declaration style" options. We will do our best to fix the problem as soon as possible. Once we resolve it, we will let you know in the context of this ticket.