Bugzilla – Bug 320993
[PATCH] make CS3014 warning (CLSCompliant(true) in non-CLSCompliant assembly)
Last modified: 2008-07-22 13:35:15 UTC
---- Reported by atsushi@ximian.com 2006-05-01 00:40:15 MST ---- In .NET 1.0 csc CLSCompliant(true) inside non-CLSCompliant assembly (CS3014) causes an error. In .NET 2.0 it became a warning. using System; [CLSCompliant (true)] public class Test { } I quickly searched CLSCompliant check related sections in ECMA-334 but I could not find any, so am guessing it is MS extension. A fix: Index: decl.cs =================================================================== --- decl.cs (revision 60029) +++ decl.cs (working copy) @@ -477,7 +477,7 @@ if (!CodeGen.Assembly.IsClsCompliant) { if (HasClsCompliantAttribute) { - Report.Error (3014, Location, + Report.Warning (3014, 1, Location, "`{0}' cannot be marked as CLS-compliant because the assembly is not marked as CLS-compliant", GetSignatureForError ()); } ---- Additional Comments From marek.safar@seznam.cz 2006-05-02 12:28:00 MST ---- Well, I am not a fan of this MS change. I would prefer to keep the CLS errors to be still errors. The reason is simple when I mark assembly CLS Compliant I expect that it will be which we cannot guranted when CLS violations are report as the warnings. I really don't understand why MS changed this. I know that Miguel already turned one of the errors to warning but I would like to keep the code consistent. ---- Additional Comments From marek.safar@seznam.cz 2006-05-02 12:30:36 MST ---- I'm CCing Miguel as he can decide. ---- Additional Comments From atsushi@ximian.com 2006-05-02 13:14:29 MST ---- The merit of this change is that you can easily turn CLS compliance off just by commenting assembly:CLSCompliant out. Otherwise you have to search all CLSCompliant attributes and comment them out. And when you want to turn it on, there is no assured way to do it, especially considering that some CLSCompliant attributes might be originally commented out. ---- Additional Comments From marek.safar@seznam.cz 2006-05-02 14:39:16 MST ---- Hmm, the interesting point but I don't understand why should one switch between comliant and not compliant on regular basis. And secondly easier way is instead of removing attribute just to change its value from true to false and an assembly is not CLS compliant. ---- Additional Comments From atsushi@ximian.com 2006-05-03 06:35:53 MST ---- When one is just copying other assemblies CLS compliance is a priori. When developing original assemblies it isn't, and such switches often happen. The second is a good point though I have never seen people writing code like: [CLSCompliant(Consts.CLSCompliance)] Unknown operating system unknown. Setting to default OS "Other".
Fixed in SVN. We now intentionally report CLS errors as warnings in all compilers.