codeformatter icon indicating copy to clipboard operation
codeformatter copied to clipboard

Unused usings should be removed

Open jterry75 opened this issue 10 years ago • 2 comments

If a file contains a using declaration that is not actually used it should be removed.

using System;
using System.Collections.Generic;

class Test
{
    public static void Main()
    {
        Console.WritLine("not using generics");
    }
}

jterry75 avatar Feb 24 '15 17:02 jterry75

I would like to take this one.

From my understanding, support for this would require a new ILocalSemanticFormattingRule that would run the diagnostics looking for CS8019 warnings and removing the offending using directives. As in the UsingLocationRule, files with preprocessor directives should probably be ignored.

amanda-mitchell avatar Mar 25 '15 05:03 amanda-mitchell

It would be great if you could specify some namespaces which should always be kept such as System.Linq.

Daniel-Svensson avatar Apr 02 '16 09:04 Daniel-Svensson