Joan Venge
Joan Venge

Reputation: 330922

Does CLSCompliant attribute care for older versions of .NET languages?

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?

Upvotes: 1

Views: 232

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1062630

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.

Upvotes: 6

Related Questions