3

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?

Chris Simmons
  • 6,924
  • 5
  • 31
  • 47

1 Answers1

7

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.

vcsjones
  • 138,677
  • 31
  • 291
  • 286
  • FWIW, someone may have committed changes to this setting in your repository if they saved it to the "Team Shared" options silo. – vcsjones May 25 '14 at 22:52
  • Yep, this fixes the problem. To your point about the "Team Shared" options, this definitely wasn't the case as I ensured I tested this with a brand new solution and project. I *know* this setting didn't work this way somewhere in the past. I want to say "just a few months ago" but I only just noticed the issue today. Thanks for the help. – Chris Simmons May 25 '14 at 23:26