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

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

문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top