为什么我的标识符被标记为不符合 CLS?
我有一个类,其中包含三个字段:
protected bool _isRunning = false;
protected readonly ParameterCollection _parameters = null;
protected readonly ParameterCollection _defaultParameters = null;
它所在的程序集被标记为符合 CLS(这是必需的),而 Visual Studio 2010 表示这三个字段的标识符不符合 CLS。他们有什么问题吗?
PS:ParameterCollection是一个类,派生自KeyedCollection,如果它是重要信息。
I have a some class, which contains three fields:
protected bool _isRunning = false;
protected readonly ParameterCollection _parameters = null;
protected readonly ParameterCollection _defaultParameters = null;
The assembly it is in is marked as CLS-compliant (it is needed), and Visual Studio 2010 says that those three fields' identifiers are not CLS-compliant. What is wrong with them?
P.S.: ParameterCollection is a class, derived from KeyedCollection, if it is important information.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下是 Microsoft 的答案,来自 Name不符合 CLS :
Here is the answer from Microsoft, from Name <membername> is not CLS-compliant:
它们以下划线开头。
有关更多详细信息,请参阅此处:
根据 MSDN:
来自 Unicode 标准 3.0 技术报告 15,附件 7:
即标识符的第一个字符可以是大写字母,
小写字母、标题大写字母、修饰符字母、其他字母或字母
数字。标识符的后续字符可以是其中任何一个,加上
非间距标记、间距组合标记、小数、连接器
标点符号和格式代码(例如右左标记)。通常情况下
在存储或比较之前应过滤掉格式化代码
标识符。
They start with an underscore.
For more details, see here:
According to MSDN:
from Unicode Standard 3.0 Technical Report 15, Annex 7:
That is, the first character of an identifier can be an uppercase letter,
lowercase letter, titlecase letter, modifier letter, other letter, or letter
number. The subsequent characters of an identifier can be any of those, plus
non-spacing marks, spacing combining marks, decimal numbers, connector
punctuations, and formatting codes (such as right-left-mark). Normally the
formatting codes should be filtered out before storing or comparing
identifiers.
要符合 CLS,标识符必须遵循 Unicode 标准技术报告 15 的附件 7 (MSDN)。这包括第一个字符为字母的要求 (源)。
To be CLS compliant, identifiers must follow the guidelines in Annex 7 of Technical Report 15 of the Unicode Standard (MSDN). This includes the requirement that the first character be a letter (source).