Question

For instance, I read that visual basic .net didn't have operator overloads before, so wouldn't be able to use a types overloaded operators, if they aren't provided as normal methods too (Add, instead of operator+).

Now that VB has this feature, would CLSCompliant attribute care if you have normal static methods like Add, Subtract instead of operator overloads only?

I have written some types without the verbal static methods, but only operator overloads, and the C# compiler didn't care. If it was a problem, it would warn me, right?

Was it helpful?

Solution

CLS compliance isn't to do with older anything - it is simply the core set of functionality that you should reasonably expect an arbitrary language to handle (when consuming your code). For example, it isn't reasonable to assume that a language is case-sensitive, so members "Foo" and "foo", while legal in C#, are not CLS compliant.

The compiler will warn you if you ask it to; add [CLSCompliant(true)] to a type / assembly / etc and it will verify your claim.

If you are an ISV, you might want to think about CLS compliance. If you are writing code just for yourself and team, you probably don't need the overhead.

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