ReSharper complains about uppercase "ID" in member "EntityID"

I have an EntityID property in a class. Resharper (5.1) says

The name EntityID does not match the Methods, Properties, and Events rule. The recommended name is "EntityId".

But IMHO is consistent with naming conventions in the Design Guide for Class Library Developers . "EntityID" should be fine:

  • Do not use abbreviations that are not commonly accepted in field calculations.
  • If necessary, use well-known abbreviations to replace the long phrase names. For example, use the user interface UI and OLAP for On-line Analytical Processing.
  • When using abbreviations, use the Pascal case or the camel case for acronyms with more than two characters. For example, use HtmlButton or htmlButton. However, you must capitalize on abbreviations that consist of only two characters, such as System.IO instead of System.Io.
  • Do not use abbreviations in identifiers or parameter names. if you must use abbreviations, use the camel case for abbreviations that consist of more than two characters, even if it contradicts the standard abbreviation of the word

* Update: * The latest version of the manual also says:

Use both characters of two-character acronyms except the first word of the identifier on a camel basis. A property named DBRate is an example of a short shorthand (DB) used as the first word of a Pascal identifier. A parameter called ioChannel is an example of a short acronym (IO), used as the first word with a camel head identifier.

Do I understand the rules correctly? If so, how can I get ReSharper to accept "EntityID" (a well-known two-letter abbreviation), but reject "HTMLReader" (it should be HtmlReader).

+24
c # naming-conventions resharper
Jul 28 '10 at 8:58
source share
4 answers

Do you want to follow the guidelines of the Frame Design Guide or want to use capitalized ID independently?

The latest version of the recommendations allows you to:

Two abbreviations that can be used in the identifiers ID and OK . The Pascal identifiers should appear as ID and OK . If used as the first word in camel skin identifier, they should be displayed as ID and OK respectively.

So, it seems that ReSharper is correct in case of ID .

Of interest, ReSharper also recommends that two character abbreviations comply with the same casing rules. This contradicts the recommendations: "Use both characters of the two-character acronyms, except the first word of the identifier with a camel skin."

+19
Jul 28 '10 at 9:15
source share

If you want ReSharper to have “ID” as a valid abbreviation for “Identification”, simply select the property, press “Alt-Enter”, and then select “Add“ ID ”to the abbreviation list” from the context of the ReSharper menu.

+42
Jul 28 '10 at 9:14
source share

The simplest solution would be to go to the ReSharper options in the “C # Name Style” section, make sure “Override General Settings” is selected, and then double-click “Methods, Properties, and Events”. Click "Add" to add a new one, and set it to "UpperCamelCase" with the name "Name Suffix".

Add additional suffixes as you like.

You can also do this using the "Advanced Settings ..." button on the "C # Name Style" page, which gives you much more flexibility, but I would not worry about that ...

+8
Jul 28 '10 at 9:04 on
source share

How about "Add" ID "to the list of abbreviations" ??

+6
Jul 28 '10 at 9:12
source share



All Articles