gpt4 book ai didi

c# - ReSharper 提示成员 "ID"中的大写字母 "EntityID"

转载 作者:IT王子 更新时间:2023-10-29 04:22:35 25 4
gpt4 key购买 nike

我在一个类中有一个属性“EntityID”。 Resharper (5.1) 说

Name 'EntityID' does not match rule 'Methods, properties and events'. Suggested name is 'EntityId'.

但是恕我直言,根据 Design Guidelines for Class Library Developers 中的命名约定. “EntityID”应该完全没问题:

  • Do not use acronyms that are not generally accepted in the computing field.
  • Where appropriate, use well-known acronyms to replace lengthy phrase names. For example, use UI for User Interface and OLAP for On-line Analytical Processing.
  • When using acronyms, use Pascal case or camel case for acronyms more than two characters long. For example, use HtmlButton or htmlButton. However, you should capitalize acronyms 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 camel case for abbreviations that consist of more than two characters, even if this contradicts the standard abbreviation of the word

*Update: * 最新版指南还说:

Do capitalize both characters of two-character acronyms, except the first word of a camel-cased identifier. A property named DBRate is an example of a short acronym (DB) used as the first word of a Pascal-cased identifier. A parameter named ioChannel is an example of a short acronym (IO) used as the first word of a camel-cased identifier.

我是否正确理解了指南?如果是这样,我如何让 ReSharper 接受“EntityID”(众所周知的两个字母首字母缩写词)但拒绝“HTMLReader”(应该是 HtmlReader)。

最佳答案

如果您希望 ReSharper 将“ID”作为“身份”的有效缩写,则只需选择属性,按“Alt-Enter”,然后从 ReSharper 上下文中选择“将‘ID’添加到缩写列表”-菜单。

关于c# - ReSharper 提示成员 "ID"中的大写字母 "EntityID",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3351304/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com