Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reference Name case is not CLS Compliant

I have a .NET 3.5 C# project that has a namespace of SampleNamespace.Tools.Sample.

If I add an assembly called "Samplenamespace.Utils.Example" to my project I get the following warning:

Identifier 'Samplenamespace' differing only in case is not CLS-compliant

Note the lower case 'n' in Samplenamespace.

I'm not even using the reference assembly in my project at the moment. Simply adding it as a reference causes the warning.

Why is the compiler complaining about this considering I'm not even exposing any references to the assembly in my public classes?

Any workaround?

like image 435
user115909 Avatar asked Jun 02 '09 11:06

user115909


People also ask

What does not CLS compliant mean?

Being CLS compliant means that you can write code that can be consumed by any language that can be compiled and run on the CLR. But CLS compliance is not required, giving you the flexibility in cases where CLS compliance would be hard or impossible to do.

How do I fix non CLS compliance?

To correct this error If the Function procedure must be CLS-compliant, change the return type to the closest CLS-compliant type. For example, in place of UInteger you might be able to use Integer if you do not need the value range above 2,147,483,647.

What is CLS compliance?

Remarks. The CLSCompliantAttribute attribute is used to indicate whether a particular program element complies with the Common Language Specification (CLS), which defines the features that any language that targets . NET must support.


1 Answers

Not all .NET languages are case sensitive (VB for example) when you have mixed namespaces like this, diffing only in case (to use the wording of the warning) your code may not be accessable to other developers.

That may not be your case, which is why it's a warning (which in my shop we treat as an error)

like image 127
Ralph Shillington Avatar answered Oct 01 '22 19:10

Ralph Shillington