Question

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.

Was it helpful?

Solution

Here is the answer from Microsoft, from Name <membername> is not CLS-compliant:

To correct this error

If you have control over the source code, change the member name so that it does not begin with an underscore.

If you require that the member name remain unchanged, remove the CLSCompliantAttribute from its definition or mark it as . You can still mark the assembly as <CLSCompliant(True)>.

OTHER TIPS

what's wrong with them?

They start with an underscore.

For more details, see here:

According to MSDN:

CLS-compliant language compilers must follow the rules of Annex 7 of Technical Report 15 of the Unicode Standard 3.0, which governs the set of characters that can start and be included in identifiers. This standard is available at http://www.unicode.org/unicode/repor...5/tr15-18.html. For two identifiers to be considered distinct, they must differ by more than just their case.

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.

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top