tags:

views:

121

answers:

1

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?

+4  A: 

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.

Marc Gravell
Thanks Marc, makes sense.
Joan Venge
I recommend CLSCompliant when writing in multiple languages, even within the same team (for example, earlier today I suggested using JSCript.NET for some tasks, and that code will need to be called from C# or VB.NET -- CLSCompliant checking, I think, will help in that case, ever were it only one programmer coding the whole).
Alex Martelli
Indeed - I was thinking of a single-language team.
Marc Gravell