开发者

How to stop ReSharper from removing unused Using statements when moving/updating Namespace declarations?

开发者 https://www.devze.com 2023-02-06 05:29 出处:网络
When using ReSharper to move/update namespace declarations, is there a way to stop ReSharper from removing unused Using statements?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消