Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the consequences of NON-CLS Compliant code in .NET?

I have a couple of nagging compiler warnings for an app that I ported from VB6 a while back regarding CLS-Compliance including:

Name '_AnIdentifier' is not CLS-Compliant.
Type of parameter 'myType' is not CLS-Compliant.

Despite this, my app seems to perform just fine from COM and Managed clients. I have seen several articles describing what to do to make the code CLS-Compliant and I probably will go ahead and do it anyway to get rid of the nagging warnings, but I am curious what the drawbacks of non-CLS compliant code are in practical terms? What limitations is this imposting that I haven't discovered yet?

like image 645
JohnFx Avatar asked Dec 02 '08 16:12

JohnFx


1 Answers

Basically, your class may not be accessible (or may act oddly, such as large positive numbers being treated as negative), when used with some .NET languages. I cannot say what languages they might be.

For example, I don't believe a language is required to recognize an identifer that begins with an underscore. C# allows it, so you're safe there, but for other languages, "_AnIdentifier" may be hidden, or have a system generated name.

like image 134
James Curran Avatar answered Nov 16 '22 02:11

James Curran