Common Language Specification
The Common Language Specification (CLS ) is a part of the Common Language Infrastructure standards, allowing the development of programming language- neutral program components. The CLS ensures that each program or any program component ( eg, a single class), CLS - compliant has been developed to fully utilize it in any other CLS-compliant programming language.
Concept of the Common Language Specification
As part of the programming language- neutral platform of a Common Language Infrastructure implementation ( eg. NET from Microsoft), it is necessary to regulate the interaction between different programming languages. Since not every programming language provides the same functionality, a cross-language programming is not automatically possible. The CLS specifies that reason a subset of the CLI standard that must be understood by any CLS-compliant programming language at least, to make language neutrality. The rules of the CLS always apply it only to public ( public or protected ) interfaces. In the internal realization of no restrictions by the CLS.
Implementation of the Common Language Specification
Most programming languages from the. NET environment, allow the developer to choose whether he wants to develop its programs or program components CLS-compliant. In addition usually the metadata attribute [ CLSCompliant (true )] is used, which the compiler (eg C # or VB.NET) instructs to check at compile time whether the CLS was observed. This is not the case, a compiler error will be generated.
All parts of the class libraries. NET are CLS-compliant.
Examples
The following list contains some examples of non- CLS-compliant elements. While this may be part of the implementation, but should not be used as part of the public interfaces.
- Unsigned data types such as uint, ulong.
- Elements (classes, methods, fields, etc. ), which differ only by a different capital letters of their name.
- Pointers (pointers ), and all other, in related constructs and language elements ( in the context of. NET called "unsafe ").
- Global static methods
- Interfaces with static methods or fields
- Classes that do not inherit from CLS-compliant classes
- Arrays of variable size or arrays that do not start at element 0
- Overloading of fields and events