Remove unnecessary import (IDE0005)

Property Value
Rule ID IDE0005
Title Remove unnecessary import
Category Style
Subcategory Unnecessary code rules
Applicable languages C# and Visual Basic

Overview

This rule flags the following unnecessary constructs:

These unnecessary constructs can be removed without changing the semantics of the code. This rule has no associated code style option.

Note

To enable this rule on build, you need to enable XML documentation comments for the project. See this issue for more details.

Example

// Code with violations
using System;
using System.IO;    // IDE0005: Using directive is unnecessary
class C
{
    public static void M()
    {
        Console.WriteLine("Hello");
    }
}

// Fixed code
using System;
class C
{
    public static void M()
    {
        Console.WriteLine("Hello");
    }
}
' Code with violations
Imports System.IO   ' IDE0005: Imports statement is unnecessary
Class C
    Public Shared Sub M()
        Console.WriteLine("Hello")
    End Sub
End Class

' Fixed code
Class C
    Public Shared Sub M()
        Console.WriteLine("Hello")
    End Sub
End Class

See also