Web Log di Adrian Florea

"You know you've achieved perfection in design, not when you have nothing more to add, but when you have nothing more to take away." Antoine de Saint-Exupery
posts - 440, comments - 2715, trackbacks - 3944

My Links

Archives

Post Categories

Image Galleries

.RO Blogs

.RO People

.RO Sites

Blogs

Furls

Links

vinCitori

Gli errori C# relativi esplicitamente al CLS

Nel file "errors.h" che contiene la lista di tutti gli errori e warning del compilatore C# del Rotor c'è scritto che "Range 3000-3999 is reserved for CLS errors". Qui sotto nella tabella, ho mappato gli errori C# riguardanti esplicitamente il CLS alle regole del CLS trasgredite:

Visual C# Compiler Error / Warning Number Rotor Error Name Summary Description CLS Rule Number CLS Rule
? ERR_CLS_NoVarArgs ? ? ? ?
CS3001 ERR_CLS_BadArgType Argument type 'type' is not CLS-compliant A public, protected, or protected internal method must accept a parameter whose type is compliant with the CLS. 11 All types appearing in a signature shall be CLS-compliant. (p. 49 del PDF)
CS3002 ERR_CLS_BadReturnType Return type of 'method' is not CLS-compliant A public, protected, or protected internal method must return a value whose type is compliant with the CLS. 11 (vedi sopra)
CS3003 ERR_CLS_BadFieldPropType Type of 'variable' is not CLS-compliant A public, protected, or protected internal variable must be of a type that is compliant with the CLS. 11, 27 (vedi sopra per 11)

[The type of a property] shall be CLS-compliant, and shall not be managed pointers (i.e. shall not be passed by reference). (p. 64 del PDF)

CS3004 ERR_CLS_BadUnicode Mixed and decomposed Unicode characters are not CLS-compliant Only composed Unicode characters are allowed in public, protected, or protected internal identifiers in order to be compliant with the CLS. 4 Assemblies shall follow Annex 7 of Technical Report 15 of the Unicode Standard 3.0 (ISBN 0-201-61633-5) governing the set of characters permitted to start and be included in identifiers. Identifiers shall be in the canonical format defined by Unicode Normalization Form C. For CLS purposes, two identifiers are the same if their lowercase mappings (as specified by the Unicode locale-insensitive, 1-1 lowercase mappings) are the same. That is, for two identifiers to be considered different under the CLS they shall differ in more than simply their case. However, in order to override an inherited definition the CLI requires the precise encoding of the original declaration be used. (p. 44 del PDF)
CS3005 ERR_CLS_BadIdentifierCase Identifier 'identifier' differing only in case is not CLS-compliant A public, protected, or protected internal identifier, which differs from another public, protected, or protected internal identifier only in the case of one or more letters, is not compliant with the CLS. 4 (vedi sopra)
CS3006 ERR_CLS_OverloadRefOut Overloaded method 'method' differing only in ref or out is not CLS-compliant A method does not cannot be overloaded based on the ref or out parameter and still comply with the CLS. 38 Properties, instance methods, and virtual methods may be overloaded based only on the number and types of their parameters, except the conversion operators named op_Implicit and op_Explicit which may also be overloaded based on their return type. (p. 72 del PDF)
CS3008 ERR_CLS_BadIdentifier Identifier 'identifier' is not CLS-compliant. A public, protected, or protected internal identifier breaks compliance with the CLS if it begins with an underscore character "_". 4 (vedi sopra)

da vedere anche il mio post precedente

CS3009 ERR_CLS_BadBase 'type': base type 'type' is not CLS-compliant. A base type was marked as not having to be compliant with the CLS in a module that was marked as being CLS compliant. Either remove the attribute that specifies the module is CLS compliant or remove the attribute that indicates the type is not CLS compliant. ? ?
CS3010 ERR_CLS_BadInterfaceMember 'member': CLS-compliant interfaces must have CLS-compliant members In a module marked with [assembly:CLCSompliant(true)], an interface contains a member marked with [CLCSompliant(false)]. Remove one of the CLS compliance attributes. 18 CLS-compliant interfaces shall not require the definition of non-CLS compliant methods in order to implement them. (p. 55 del PDF)
CS3011 ERR_CLS_NoAbstractMembers 'member': only CLS-compliant members can be abstract A class member cannot be both abstract and non-compliant with the CLS. The CLS specifies that all class members shall be implemented. ? ?
CS3012 ERR_WRN_NotOnModules
Compiler Warning (level 1)
You must specify the CLSCompliant attribute on the assembly. In order for a module to be compliant with the CLS through [module:System.CLCSompliant(true)], it must be built with the /target:module compiler option. - -
CS3013 ERR_CLS_ModuleMissingCLS Added module is not CLS-compliant, or is missing CLSCompliant attribute. A module that was compiled with the /target:module compiler option was added to a compilation with /addmodule. However, the module's compliance with the CLS does not agree with the CLS state of the current compilation.

CLS compliance is indicated with the module attribute. For example, [module:CLSCompliant(true)] indicates that the module is CLS compliant, and [module:CLSCompliant(false)] indicates that the module is not CLS compliant. The default is [module:CLSCompliant(false)].

-

-

CS3014 ERR_CLS_AssemblyNotCLS 'member' cannot be marked as CLS compliant because the assembly is not marked as compliant In a source code file where compliance with the CLS was declined, a construct in the file was marked as being CLS compliant. This is not allowed. Remove one of the CLSCompliant specifications. 2 Members of non-CLS compliant types shall not be marked CLS-compliant. (p. 36 del PDF)
CS3015 ERR_CLS_BadAttributeType 'method signature' has no accessible constructors which use only CLS compliant types. To be compliant with the CLS, the argument list of an attribute class cannot contain an array. 34 The CLS only allows a subset of the encodings of custom attributes. The only types that shall appear in these encodings are: System.Type, System.String, System.Char, System.Boolean, System.Byte, System.Int16, System.Int32, System.Int64, System.Single, System.Double, and any enumeration type based on a CLS-compliant base integer type. (p. 69 del PDF)
CS3016 ERR_CLS_ArrayArgumentToAttribute Arrays as attribute arguments is not CLS-compliant. It is not compliant with the CLS to pass an array to an attribute. 34 (vedi sopra)

E' interessante notare che il warning CS3012, l'unico warning in questa serie composta solo da errori di non conformità al CLS, riguarda non il linguaggio ma le opzioni di compilazione che devono essere coerenti con il codice. All'inizio mi sono chiesto: ma sarà per questo che i tizi del Visual C# Team l'hanno scelto come warning e non come errore? Poi, ho visto anche la situazione simile dell'errore CS3013, che non è warning ma errore e quindi il ragionamento forse non vale. Sono stato un po' indeciso tra mettere un punto di domanda e mettere un trattino per questi due, ma alla fine ho scelto il trattino.

Un'altra osservazione è che il compilatore C# del Rotor sembra avere un errore in più per il CLS, ERR_CLS_NoVarArgs, molto probabilmente riguardante la CLS Rule 15: "The varargs constraint is not part of the CLS, and the only calling convention supported by the CLS is the standard managed calling convention." (p. 51 del PDF). Ho lasciato però un punto di domanda.

Non ho trovato una regola CLS corrispondente all'errore CS3009, anche se sarei tentato al limite di associargli la CLS Rule 20: "CLS-compliant classes, value types, and interfaces shall not require the implementation of non-CLS-compliant interfaces." (p. 58 del PDF). La regola però si riferisce chiaramente a interface non conforme al CLS.

La stessa CLS Rule 20 l'associerei all'errore CS3011 con la stessa osservazione.

Qualche commento?

Print | posted on lunedì 29 novembre 2004 02:19 | Filed Under [ Carillon .NET CLS ]

Powered by:
Powered By Subtext Powered By ASP.NET