Bug 320993 (MONO78252) - [PATCH] make CS3014 warning (CLSCompliant(true) in non-CLSCompliant assembly)
Summary: [PATCH] make CS3014 warning (CLSCompliant(true) in non-CLSCompliant assembly)
Status: RESOLVED FIXED
Alias: MONO78252
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Minor
Target Milestone: ---
Assignee: Marek Safar
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-01 07:40 UTC by Atsushi Enomoto
Modified: 2008-07-22 13:35 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:57: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".

Comment 1 Marek Safar 2008-07-22 13:35:15 UTC
Fixed in SVN.

We now intentionally report CLS errors as warnings in all compilers.