Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are my identifiers marked as not CLS-compliant? [duplicate]

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.

like image 498
Vasya Avatar asked Dec 28 '25 02:12

Vasya


1 Answers

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

like image 145
James Culshaw Avatar answered Dec 30 '25 16:12

James Culshaw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!