1

In my solution, I have a method setup like this

void OnFooLoaded(param bar)
{
    // method body
}

Using ReSharper 7, it suggests that I can make the method either public, internal or protected. I cannot seem to figure out where I can change this, so the method signature has to have a visibility modifier (i.e private, public etc.) Should I look under Resharper Options -> Code Inspection -> Inspection Severity or is there somewhere else I'm missing a setting?

Nicklas Pouey-Winger
  • 3,023
  • 6
  • 43
  • 75
  • Why do you want to turn this off? Is there a special reason why you would not want to specify the visibillity? http://csharp.net-tutorials.com/classes/visibility/ (notes about visibillity) – ruffen Feb 20 '13 at 12:37
  • @ruffen I use implied visibility wherever possible. It's a personal preference. – millimoose Feb 20 '13 at 12:38
  • @niwi What exactly do you want to disable? The suggestion to explicitly add an implied visibility modifier? (`Code Editing > C# > Formatting Style > Other > Mofidiers`) Or the suggestion to automatically restrict the visibility depending on where the method is used? – millimoose Feb 20 '13 at 12:38
  • I'm sorry guys, I had phrased my question wrong. Or rather, asked the wrong question. Please see edited ver. :) – Nicklas Pouey-Winger Feb 20 '13 at 12:51

1 Answers1

1

In ReSharper, to add access modifiers or not is a formatting preference. You can change it at ReSharper | Options -> Code Editing | C# | Formatting Style | Other | Modifiers. Turn on Use explicit ... to always add modifiers when making code cleanup or turn them off not to do it.

But ReSharper can't highlight or underline places where wrong formatting style is used (for example, where there is no access modifiers). You should try StyleCop for this.

Dmitry Osinovskiy
  • 9,999
  • 1
  • 47
  • 38
  • For me, this doesn't really do anything. What I want to do is to underline the method without a modifier with a red (error) line, telling the user that a modifier has to be used. All it does now, with the explicit checkboxes turned off, is giving me the suggestion to set the method to public, internal or protected. Thanks so far. – Nicklas Pouey-Winger Feb 21 '13 at 07:33
  • 1
    Sorry, didn't understand you. Updated my answer. In short - try StyleCop, it's free and integrates well with ReSharper. – Dmitry Osinovskiy Feb 21 '13 at 07:57