How to stop ReSharper from removing unused Using statements when moving/updating Namespace declarations?
When using ReSharper to move/update namespace declarations, is there a way to stop ReSharper from removing unused Using statements?
In other words, if I have a class such as:
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
namespace Foo.Bar
{
class MyClass
{
List<string> Names { get; set; }
}
}
And I want to move it into the Foo.Bar.Utilities namespace using ReSharper, Resharper will remove all the unused Using state开发者_如何学JAVAments and leave me with:
using System.Collections.Generic;
namespace Foo.Bar.Utilities
{
class MyClass
{
List<string> Names { get; set; }
}
}
However, I do not want ReSharper to touch my Using statements while moving the namespace declaration. I'd prefer to have the result as:
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
namespace Foo.Bar.Utilities
{
class MyClass
{
List<string> Names { get; set; }
}
}
I don't think you can do this unequivocally.
However, there is an option to specify namespaces that should not be removed (Resharper Options -> C# -> Namespace Imports), but you need to know which ones you don't want it to remove.
精彩评论