Is there a setting in Visual Studio (or Resharper) that allows you to specify what namespaces should be default and which scope they are put in?
The default for an MVC project for example is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Namespace
{
public class Class1
{
}
}
but Resharper and Stylecop complain:
All using directives must be placed inside of the namespace. [StyleCop Rule: SA1200]
Using directive is not required by the code and can be safely removed
Is there a way to make the default simply:
namespace Namespace
{
public class Class1
{
}
}
You can set this in Re-sharper.
Re-sharper > Options > C# > Namespace Imports > Add using directive to the deepest scope.
Update: As of VS2015 and Resharper10, this has moved. It is now under:
Code Editing > C# > Code Style > Reference qualification > Add 'using' directive to deepest scope