Perpetualcoder
Perpetualcoder

Reputation: 13591

Resharper Tip/Trick... is this possible?

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.EvenMoreStuff;
  #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

Upvotes: 4

Views: 1314

Answers (1)

bdukes
bdukes

Reputation: 156065

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

Upvotes: 9

Related Questions