Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deal with ReSharper's name suggestions?

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?

like image 536
Jichao Avatar asked Oct 19 '10 08:10

Jichao


2 Answers

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
like image 134
M.Hassan Avatar answered Sep 27 '22 22:09

M.Hassan


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.

like image 44
Neowizard Avatar answered Sep 27 '22 21:09

Neowizard