How to deal with ReSharper's name suggestions?

10,404

Solution 1

ReSharper's advice is (in most cases) useful, but sometimes it misses the target and can even be a bit annoying.

You have three solutions for this;

  1. Edit the ReSharper's definitions to match your liking (this is possible by selecting "edit X rule settings" from the quick fix menu on the left)

  2. Hide the annoying ReSharper message (either locally with a comment or globally by changing the settings for this type of message. Both are possible from the quick fix menu)

  3. Ignore ReSharper's message when it's simply useless.

No matter what you choose, make sure your selection encapsulates your entire work (as well as your team's work if you're a part of one). For instance, in the case of option 3, make a list of situations where ReSharper is ignored.

Keeping your code consistent is vital to any project (be it small or large) and should be your first guideline when thinking about ReSharper.

Solution 2

There is a simple way to disable ReSharper's inconsistent naming evaluation check for an entire file/class.

By adding the following comment to the top of the file/class, ReSharper will not evaluate the naming conventions when analyzing the file/class.

// ReSharper disable InconsistentNaming 

For a code fragment, you can:

// ReSharper disable InconsistentNaming
private void btnCreate_Click(object sender, RoutedEventArgs e)
// ReSharper restore InconsistentNaming
{
    //.....
}

List of suggested comments provided by ReSharper:

// ReSharper disable InconsistentNaming
// ReSharper restore InconsistentNaming

// ReSharper disable CodeCleanup
// ReSharper restore CodeCleanup

Solution 3

Personally, I suppress those warnings and then it ignores them.

If you go to ReSharper > then choose Inspection Severity in the Code Inspection menu, you can switch this off.

Solution 4

To turn the suggestion off, you can change ReSharper's Inspection Severity.

ReSharper > Options > Code Inspection > Inspection Severity > Inconsistent Naming

You can also change or create custom Naming Styles for individual languages.

ReSharper > Options > C# > Naming Style > Advanced Settings

More information about creating custom Naming Styles can be found on JetBrains' and on devloq.

Solution 5

I do not follow all r# suggestions. The one I don't like I change, the one that can't be changed I turn it off (we have our own guidelines).

Share:
10,404

Related videos on Youtube

Jichao
Author by

Jichao

Full stack hello world developer

Updated on June 04, 2022

Comments

  • Jichao
    Jichao almost 2 years

    Always, I have got the following message:

    name 'byteProivder_LengthChanged' does not match 'Methods, properities and events'. Suggested name is 'ByteProviderLengthChanged'

    Not even the VS generated method name could get away from this suggestion. For example FormXXX_Load is adviced to change to FormXXXLoad.

    So what should I do? Should I follow the name suggestion or just keep the VS style? If I follow the name suggestion, how to configure the ReSharper and let it change the name automatically? If I do not follow the ReSharper way, how could I turn this name suggestion option off?

  • Eamon Nerbonne
    Eamon Nerbonne over 13 years
    A naming convention is one thing; an explicit convention is another; and machine-verification of a convention that probably doesn't match your project's reality is again different.
  • Klaus Byskov Pedersen
    Klaus Byskov Pedersen over 13 years
    In my opinion you define your own project's reality.
  • KulaGGin
    KulaGGin about 5 years
    My problem with ReSharper isn't naming conventions. I like to follow naming conventions. I edited it a bit and it's very nice. But there are 500 other inspections, which are really-really annoying. And what's even more annoying is that I had to uncheck 500 of checkboxes in Inspection Severity manually, one by one. Because if I don't, I get 500 suggestions per project. And that's if project is small.