The Artima Developer Community
Sponsored Link

.NET Buzz Forum
CLS Compliance testing is useless

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Frans Bouma

Posts: 265
Nickname: fbouma
Registered: Aug, 2003

Frans Bouma is a senior software engineer for Solutions Design
CLS Compliance testing is useless Posted: Aug 2, 2003 1:13 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Frans Bouma.
Original Post: CLS Compliance testing is useless
Feed Title: Frans Bouma's blog
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/fbouma/Rss.aspx
Feed Description: Generator.CreateCoolTool();
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Frans Bouma
Latest Posts From Frans Bouma's blog

Advertisement

After reading Patrick Steele's blog about the failure of CLS Compliance testing in VB.NET, I thought he was wrong, because he uses UInt32 as type, which is a native system type (i.e. a .NET type: System.UInt32).

However, he was right. The C# compiler fails to compile a simple statement like (when CLS Compliance testing is turned on via an attribute):

public System.UInt32 Test;

Correct behaviour of the C# compiler? No. The reason why the C# compiler makes a mistake here is that I use a .NET type, System.UInt32, which is available to any .NET language (it's in the .NET System namespace after all). Therefor, if I specify a public identifier with this type, no matter what language is consuming the type, it can use it. Proof of this is VB.NET, which lacks an unsigned integer type, but can perfectly work with System.UInt32. Also, why would System.UInt32 fail CLS Compliance, but would another value type like System.Data.SqlTypes.SqlString not fail CLS Compliance testing (although it exposes implicit operators not usable in VB.NET!) ?

So is CLS Compliance testing of any use? Not that I'm aware of. If native .NET types, located in the System namespace, can't be used as types for public identifiers (like parameters, properties, return values etc.), why are these types defined in the first place? Because apparently some languages can't use them, otherwise these native, .NET types wouldn't cause a CLS Compliance violation!

Microsoft: or come up with valid rules, founded on solid reasoning, for CLS Compliance testing or stop with the CLS Compliance testing altogether, since at the moment it cries fool when compiling perfect usable code.

The conclusion of Patrick's article shouldn't be: why doesn't the VB.NET compiler test correctly, but why does the C# compiler test incorrectly.

Read: CLS Compliance testing is useless

Topic: End-to-End Analyze Script for Keeping a VSS Database Healthy Previous Topic   Next Topic Topic: Late Junction

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use