Resharper suggest void method to public, internal or protected - how to always have demand access modifier

StackOverflow https://stackoverflow.com/questions/14980006

Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top