Why cls compliant




















Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. A programming element can contain one or more underscores, but to be compliant with the Language Independence and Language-Independent Components CLS , it must not begin with an underscore. See Declared Element Names. When you apply the CLSCompliantAttribute to a programming element, you set the attribute's isCompliant parameter to either True or False to indicate compliance or noncompliance.

There is no default for this parameter, and you must supply a value. By default, this message is a warning. View All. A V Mahesh Updated date Mar 30, Unsigned types should not be part of the public interface of the class. What this means is public fields should not have unsigned types like uint or ulong, public methods should not return unsigned types, parameters passed to public function should not have unsigned types. However unsigned types can be part of private members.

Unsafe types like pointers should not be used with public members. However they can be used with private members. Class names and member names should not differ only based on their case. Only properties and methods may be overloaded, Operators should not be overloaded. Following are the some situations which may cause the C compiler to raise an error If your class methods that are identical but differ only by 'out' or 'ref'.

Only the fact that an item is an array and the element type of the array shall be required to distinguish between overloads. When overloading is based on two or more array types the element types shall be named types. Unmanaged pointer types are not CLS-compliant. CLS-compliant interfaces shall not require the definition of non-CLS compliant methods in order to implement them.

CLS-compliant interfaces shall not define static methods, nor shall they define fields. CLS-compliant classes, value types, and interfaces shall not require the implementation of non-CLS-compliant members. An object constructor shall call some instance constructor of its base class before any access occurs to inherited instance data. This does not apply to value types, which need not have constructors.

An object constructor shall not be called except as part of the creation of an object, and an object shall not be initialized twice. Object is CLS-compliant. The methods that implement the getter and setter methods of a property shall be marked SpecialName in the metadata. No longer used. The type of a property shall be the return type of the getter and the type of the last argument of the setter.

The types of the parameters of the property shall be the types of the parameters to the getter and the types of all but the final parameter of the setter. All of these types shall be CLS-compliant, and shall not be managed pointers i. Properties shall adhere to a specific naming pattern. The SpecialName attribute referred to in CLS rule 24 shall be ignored in appropriate name comparisons and shall adhere to identifier rules. A property shall have a getter method, a setter method, or both.

The methods that implement an event shall be marked SpecialName in the metadata. The accessibility of an event and of its accessors shall be identical.

The add and remove methods for an event shall both either be present or absent. The add and remove methods for an event shall each take one parameter whose type defines the type of the event and that shall be derived from System. Events shall adhere to a specific naming pattern. The SpecialName attribute referred to in CLS rule 29 shall be ignored in appropriate name comparisons and shall adhere to identifier rules.

The CLS only allows a subset of the encodings of custom attributes. The only types that shall appear in these encodings are see Partition IV : System. Type , System.

String , System. Char , System. Boolean , System. Byte , System. Int16 , System.



0コメント

  • 1000 / 1000