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

2

13

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?

Detergent answered 2/12, 2008 at 16:11 Comment(0)
M
10

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.

Monasticism answered 2/12, 2008 at 16:19 Comment(0)
C
4

I've run into issues with obfuscation tools generating incorrect obfuscated code when code that isn't CLS-compliant is obfuscated.

Cochard answered 2/12, 2008 at 16:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.