Vadim's Weblog

Never stop learning.

Disable automatic private modifier in ReSharper

Posted by Vadim on October 20, 2008

If you use ReSharper, you notice that every time you create a global class variable without a modifier, ReSharper will add a private modifier for you.

You type:

string name;

ReSharper formats:

private string name;

Some people may be prefer this way.  I personally don’t see what values it adds.  My brain already knows that if there’s no modifier for a variable, than this variable is private.  I don’t need any extra information for my brain to process and filter.

Luckily for me ReSharper has an option to turn this feature off.

  1. Lunch ReSharper – Options dialog box.
  2. On the left part of the dialog select C#/Formatting Style/Other
  3. On the right part of the dialog uncheck ‘Use explicit private modifier’.

ReSharper_Options_private_modifier

kick it on DotNetKicks.com

6 Responses to “Disable automatic private modifier in ReSharper”

  1. Jeff Brown said

    I strongly prefer explicit “private” and “internal” myself.

    Of course that might just be a throwback to my Java days where lack of an accessibility keyword meant “package” visibility. A subtle gotcha…

  2. This setting appears to have disappeared on the latest version of Resharper (10.1), any idea where it has moved to? I can’t find it.

    • Vadim said

      I don’t have a copy of R# 10 yet. In 9.2 it’s not in Formatting Style anymore. You can find ‘Use explicit private modifier’ in Code Style under Modifiers section. Let me know if you still cannot find it in 10.1.

    • Anonymous said

      Ciaran, I just updated my version of R# to 10 and the option is there. Go to Options > Code Editing > C# > Code Style. When there go to Modifiers and change from Explicit to Implicit for the first item “Prefer explicit/implicit private modifier for type members”.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: