How to deal with ReSharper offers?

I always get the following message:

The name 'byteProivder_LengthChanged' does not match 'Methods, Properties, and Events'. The suggested name is "ByteProviderLengthChanged"

Even the VS generated method name could not do without this sentence. For example, change FormXXX_Load 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 do I configure ReSharper and let it automatically change the name? If I donโ€™t follow the ReSharper path, how can I turn off this name suggestion option?

+4
source share
10 answers

The ReSharper tip (in most cases) is useful, but sometimes it misses the target and can even be a little annoying.

You have three solutions for this;

  1. Edit the ReSharper definitions according to your preference (this can be done by selecting "change rule X settings" in the quick fix menu on the left)

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

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

No matter what you choose, make sure that your choice covers all of your work (as well as the work of your team if you are part of one). For example, in case of option 3, make a list of situations in which ReSharper is ignored.

Keeping your code consistent is vital for any project (whether small or large) and should be your first guide when you think of ReSharper.

+3
source

Personally, I suppress these warnings and then ignore them

if you go to ReSharper>, then select "Control Level" in the "Code Verification" menu, then you can disable it

+3
source

To disable an offer, you can change the severity of the ReSharper check.

ReShaper> Options> Code Validation> Verification Level> Inconsistent naming

You can also change or create custom name styles for individual languages.

ReShaper> Options> C #> Name Style> Advanced Settings

More information on creating custom naming styles can be found on JetBrains and on devloq .

+3
source

I do not follow all the advice. The one that I do not like, I change, the one that cannot be changed, I turn off (we have our own recommendations).

+2
source

There is an easy way to disable ReSharper's inconsistent name resolution check for the entire file / class.

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

 // ReSharper disable InconsistentNaming 

For a piece of code, 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 
+2
source

You can also use StyleCop for ReSharper and define your own rules or change the default behavior to suit your style.

+1
source

You can suppress one instance of a warning by adding the following comment before the warning line, for example, for the following warning:

The name Counter does not match the Local Function rule. The recommended name is "counter".

Disable:

 // ReSharper disable once InconsistentNaming function Counter() { this.pending = 0; this.succeeded = 0; this.failed = 0; } 
+1
source

ReSharper is trying to get you to stick to Microsoftโ€™s own naming conventions, which is a good idea, especially if your team no longer uses any naming conventions. Using a naming convention gives your code greater readability and a more consistent API.

0
source

If you want to disable some code checks, I think the easiest way is to select "Validation options for ...." from the menu that appears on the right side in the editor (for this specific error / warning), then a popup will appear, and You can change the behavior of these types of checks. Last option: "Don't show" does the trick.

This applies to R # 5.0 and possibly 4x.

In general, you should use coding standards that you think will fit your needs.

0
source

Here's a screenshot in case you have trouble finding ReSharper settings:

After pressing Resharper Menu โ†’ Options:

Inconsistent Naming Options

0
source

All Articles