ReSharper ignoring naming rules on any method with an underscore. New "feature" or misconfiguration?

770 views Asked by At

I have ReSharper v8.2.1 (Build 8.2.1000.4556) running in Visual Studio 2013. I just noticed behavior where if I put an underscore in the name of a method, the "Inconsistent Naming" warning goes away completely. For example:

public void zzz()
{
    // The ReSharper warning appears for this one, zzz()
}

public void zz_z()
{
    // But not this one
}

I just re-set my ReSharper settings to factory defaults to make sure I didn't have something else interfering and the same behavior persists.

I checked the naming conventions under "Methods, properties, and events" (the effective setting producing the warning for "zzz()") and the Name style is set to "UpperCamelCase" as I've always known it to be. None of the "underscores tolerant" settings are selected.

So, the question is, is this a new "feature", do I have something configured incorrectly somewhere, or am I missing something completely obvious?

1

There are 1 answers

2
vcsjones On BEST ANSWER

I'm not sure if this is something new in 8.1 or not, but Resharper doesn't warn on underscore method names because that is the convention for event handlers, like object_Event(...). Resharper doesn't flag it since it's trying to allow for that convention, and that's what a lot of code generators produce.

You can change this by going to Resharper -> Options -> Code Editing -> C# -> Naming Style -> Advanced Settings... then changing "Event subscriptions on fields" to something other than $object$_$event$, such as $object$On$event$.

Then it will start doing analysis on methods with underscores in their name.