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?
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
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;
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)
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)
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.
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.
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.
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).
You can suppress a single warning instance by adding the following comment before the line with the warning, for example, for the following warning:
Name 'Counter' does not match rule 'Local Function'. Suggested name is 'counter'.
Disable like this:
// ReSharper disable once InconsistentNaming
function Counter() {
this.pending = 0;
this.succeeded = 0;
this.failed = 0;
}
You can also use StyleCop for ReSharper and define your own rules or modify default behaviour to follow your style.
If you want to turn off some code inspections, i think, the easiest way is to choice "Inspections options for...." from the menu that shows on the right side in editor (for that particular error/warning). Then a popup will show up and you can change the behavior of that type of inspections. Last option:"Do not show" does the trick.
This applies to R# 5.0 and probably 4x as well.
In general, you should use the coding standards that you think will fit your needs.
ReSharper is trying to make you adhere to Microsoft's own naming guidelines which is a good idea, especially if your team is not using any naming conventions already. Using a naming convention gives your code greater readability and a more consistent API.
Here is the screenshot just in case you are having problem looking for ReSharper settings:
Upon clicking Resharper Menu -> Options:
精彩评论