4

我怎样才能让 Resharper 转换代码文件,如

using Stuff;
using Stuff.MoreStuff;
using Stuff.MoreStuff.EvenMoreStuff;

namespace CoolStuff 
{
// src code
}

namespace CoolStuff 
{
  #region Using Statements
  using Stuff;
  using Stuff.MoreStuff;
  using Stuff.MoreStuff.EvenMoreStuff;
  #endregion

// src code
}

我只是喜欢这种方式,它“我认为”也是 stylecop 规则之一。我将不胜感激任何帮助。

谢谢

4

1 回答 1

9

在您的 ReSharper 选项中,在 C#->Formatting Style 下找到命名空间导入页面。在那里,选中“将 using 指令添加到最深范围”复选框。

然后,转到底部的工具部分,然后选择代码清理页面。创建一个新的清理配置文件,并选中“Embrace 'using' directives in region”选项,在下一行提供“Using Statements”作为区域名称。确保选中“优化'使用'指令”。您可以根据需要打开或关闭其他清理设置。

Then, you can run code cleanup on a file by pressing Ctrl+E, C (or Ctrl+E, F if you've set that profile as your silent clean-up profile).

于 2010-02-04T22:37:51.937 回答