What follows is a description of how I set about changing a couple of those ReSharper formatting and layout rules.
Using directives before namespaces
There may be arguments for putting using directives inside the namespace but our standards – and my preference - require they appear at the top of the file. I’m not alone in this.
By default when ReSharper helps out by adding using directives for you it adds them inside the namespace. To make ReSharper follow this convention I did this:
- In Visual Studio go to ReSharper > Options.
- Navigate to Code Editing > C# > Namespace Imports.
- Deselect “Add using directives to the deepest scope”.
- Save the changes.
Private instance fields prefixed with an underscore
To add an underscore to private instance fields do the following:
- In Visual Studio go to ReSharper > Options.
- Navigate to Code Editing > C# > Naming Style.
- Double-click on “Instance Fields (private).
- Add a Name Prefix and click Set.
- Save the changes.
Don't use 'this' qualifier for instance members
To prevent ReSharper from including "this." for instance members:
- In Visual Studio go to ReSharper > Options.
- Navigate to Code Editing > C# > Formatting Style > Other.
- Scroll down to "Force "this." qualifier for instance member" and select "Do not use" from the dropdown list.
- Save the changes.