Resharper Not Recognizing Acronym

I'm trying to clear the warnings that R # 6.1 generates for my classes, and one of the problems that ReSharper reports is that my variable capitalization is incorrect. For example, I have var RECDLeft = new RECD(); , and I recommend changing it to var recdLeft = new RECD() , even though it is an abbreviation defined in the list. I manually added the abbreviation RECD to the list of abbreviations because it did not ask me to add it to the quick fix menu. I noticed that if I call the variable `var aRECDLeft ', it will correctly recognize the abbreviation. Are there any reasons why abbreviations are not recognized at the beginning of the variable name? And is there a way to make R # recognize this usage, in addition to moving the acronym to the second word?

Thanks Mark Smith

+4
source share
3 answers

In answer to your first question, I think R # is trying to comply with Microsoft C # conventions for abbreviations:

Capitalization rules for reductions

Use both characters of two-character acronyms, except for the first word of the identifier with a camel line.

A property named DBRate is an example of a short acronym (DB) used as the first word of an identifier with pascal. A parameter named ioChannel is an example of a short acronym (IO) used as the first word of an identifier with a camel line.

Use only the first character of abbreviations with three or more characters, except for the first word of the identifier with a camel line.

A class called XmlWriter is an example of a long abbreviation used as the first word of an identifier with a pascal. A parameter named htmlReader is an example of a long abbreviation used as the first word of an identifier with a camel line.

Do not use any of the characters of any abbreviations, regardless of their length, at the beginning of the identifier with a camel wrapper.

A parameter named xmlStream is an example of a long abbreviation (xml) used as the first word of an identifier with a camel shell. A parameter named dbServerName is an example of a short abbreviation (db) used as the first word of an identifier with a camel shell.

+3
source

I assume the problem is that although an abbreviation has been added, you still break the rule that variable names begin with lower case. You will need to add a special rule for variable names that will allow them to start with this acronym. This is not the same as adding an abbreviation to the list.

+2
source

As Syrid correctly points out, this is a special case of naming, requiring the introduction of a special naming rule for local variables, which will be checked in addition to the default rule. Here is what you should do:

  • Go to ReSharper> Options> Code Editing> C #> C # Name Style
  • Select Local Variables and click "Edit."
  • In the Edit Rules dialog box, by default you see one single rule, lowerCamelCase. However, you could change it to a different style.
  • What you need to do is add another naming rule by clicking "Add" and set both the name prefix (RECD in your case) and the UpperCamelCase style. If you add only the prefix, ReSharper will continue the bitches (and give some funny suggestions for renaming), because you also say "Left" instead of "left".

If you have other similar abbreviations, you should add an additional local warrang rule for each of them (a full list of known abbreviations is available in the C # name style> Advanced settings> Abbreviations as plain text.) This is not very convenient, but this does not mean that you have a simple naming standard)

Hope this helps.

+2
source

Source: https://habr.com/ru/post/1400590/


All Articles