CLSCompliant is Still Off By Default

With .NET 2.0 and VS2005, I half expected CLSCompliant to be turned on by default; however, it wasn't and I kind of understood the decision (it was still kind of early in the product cycle, a lot of developers didn't understand the implications, etc). But now that .NET 3.0, .NET 3.5, and VS2008 have been released, I fully expected CLSCompliant to be on by default - and it's not.

Can anyone at Microsoft explain why that's the case and how that decision was made, or even if it was discussed? I'm a firm believer that all .NET code should default to be CLSCompliant and only in exception cases should it be turned off. With CLSCompliant off by default, there are numerous warnings the compiler doesn't show in the build output that developers should know about. And it's been my experience that with it off by default, most developers don't take a second to turn it on. Heck, I'm willing to bet that most developers assume they *are* writing CLSCompliant .NET code when in fact they aren't. Of course, that also assumes that most .NET developers know what CLSCompliant is and how to turn it on or off, and I'm not sure that's the case.

For me, writing CLSCompliant .NET code is key to having a solid design in place, especially with regards to API design and all public-facing classes and members, so for it to be off by default is an oversight.

If anyone at Microsoft can shed light on this, I'd love to hear it. Seriously.

Print | posted on Wednesday, December 19, 2007 2:15 AM

Feedback

# re: CLSCompliant is Still Off By Default

Gravatar left by Todd Grigsby at 12/28/2007 1:14 PM
I'm assuming you mean that having CLSCompliant turned on is *one aspect* of solid design, and by that you mean the datatypes being used are one thing you don't have to worry about. In situations where the datatypes have been decided upon to make integration with legacy systems easier, I would think that CLSCompliance can actually be an unnecessary hurdle. But being new to .NET, I'd love to hear your view on that.

# re: CLSCompliant is Still Off By Default

Gravatar left by Dave at 12/28/2007 1:37 PM
Todd - yes, turning CLSCompliant is only *one* aspect of solid design, but it's not just about datatypes. For instance, C# allows you to expose a public method named getCustomer and another public method named GetCustomer (because of C#'s case-sensitivity), which is generally considered bad design. With CLSCompliant off by default, this is allowable and the compiler won't even throw a warning. But if CLSCompliant was turned on, then something like this wouldn't be allowed to happen.
Comments have been closed on this topic.