开发者

Resharper Tip/Trick... is this possible?

开发者 https://www.devze.com 2022-12-19 10:10 出处:网络
How can I have Resharper convert code file like using Stuff; using Stuff.MoreStuff; using Stuff.MoreStuff.EvenMoreStuff;

How can I have Resharper convert code file like

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

namespace CoolStuff 
{
// src code
}

To

namespace CoolStuff 
{
  #region Using Statements
  using Stuff;
  using Stuff.MoreStuff;
  using Stuff.MoreStuff.EvenMoreStu开发者_Python百科ff;
  #endregion

// src code
}

I just like it this way, it "I think" is in one of the stylecop rules too. I would appreciate any kind of help.

Thanks


In your ReSharper Options, find the Namespace Imports page under C#->Formatting Style. In there, check the "Add using directive to the deepest scope" check box.

Then, go down to the bottom Tools section, and select the Code Cleanup page. Create a new cleanup profile, and check the "Embrace 'using' directives in region" option, supplying "Using Statements" as the region name on the next line. Make sure that "Optimize 'using' directives" is checked. You can turn the other cleanup settings on or off as you like.

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).

0

精彩评论

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

关注公众号