dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.06k stars 4.04k forks source link

Feature request: refactoring for adding a using / simplifying a name #38095

Open stephentoub opened 5 years ago

stephentoub commented 5 years ago

Consider:

using System;
using System.Threading;

class Program
{
    static void Main()
    {
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        Thread.Sleep(1000);
        Console.WriteLine(sw.Elapsed);
    }
}

With a one-step operation, I'd like to be able to transform this to:

using System;
using System.Diagnostics;
using System.Threading;

class Program
{
    static void Main()
    {
        var sw = new Stopwatch();
        sw.Start();
        Thread.Sleep(1000);
        Console.WriteLine(sw.Elapsed);
    }
}

adding a using and simplifying the associated type name (today no refactorings are offered for the System.Diagnostics.Stopwatch reference).

NTaylorMullen commented 3 years ago

Design Meeting Notes:

image