[Mono-list] Mono & CLS compliant code
Jeroen Janssen
japj@xs4all.nl
Wed, 05 Feb 2003 20:43:08 +0100
Hello,
I have been experimenting with enabling CLS compliance for a certain
assembly (Mono.PEToolkit, but maybe I better start with a different one).
(this is the first thing that is triggered by the FxCop rules).
Anyway, you can trigger csc to check for CLS compliance by adding the
following in a source file of the assembly:
[assembly: CLSCompliantAttribute(true)]
Now, when I build things with csc I get a bunch of errors, (obviously)
because csc now checks for CLS compliance.
Errors (in Mono.PEToolkit) include the following:
* MDToken.cs(135,44): error CS3001: Argument type 'uint' is not
CLS-compliant
* MDUtils.cs(50,41): error CS3001: Argument type 'void*' is not
CLS-compliant
* Characteristics.cs(10,14): error CS3009:
'Mono.PEToolkit.Characteristics': base type 'ushort' is not CLS-compliant
* Mono.PEToolkit\Image.cs(211,23): error CS3005: Identifier
'Mono.PEToolkit.Image.MetaDataRoot' differing only in case is not
CLS-compliant
* LEBitConverter.cs(115,41): error CS3001: Argument type 'ulong' is not
CLS-compliant
* LEBitConverter.cs(115,24): error CS3002: Return type of
'Mono.PEToolkit.LEBitConverter.SwapUInt64(ulong)' is not CLS-compliant
Now before I go ahead and start working on a patch, I really want to
know if we want everything to be CLS compliant. Looking at the errors I get,
it probably wouldn't hurt if everyone else followed some kind of
guideline to write CLS compliant code (for new code). I certainly don't
want to break any currently working code.
Is there a list of 'official' assemblies & if they are CLS compliant?
(my guess is at least those officially being CLS compliant must be done)
Next question is, how difficult would it be to add CLS compliance checks
in mcs (when the CLSCompliantAttribute is true)?
Best regards,
Jeroen Janssen