System Namespace
Indicates whether a program element is compliant with the Common Language Specification ( CLS ). This class cannot be inherited.
If no CLSCompliantAttribute is applied to a program element, by default:
- The assembly is not CLS-compliant.
- The type is CLS-compliant only if its enclosing type or assembly is CLS-compliant.
- The member is CLS-compliant only if the type in which the member is CLS-compliant.
If an assembly is marked as CLS-compliant, any publicly exposed type in the assembly that is not CLS-compliant must be marked with CLSCompliantAttribute using a false argument. Similarly, if a class is marked as CLS-compliant, you must individually mark all members that are not CLS-compliant. All non-compliant members must provide corresponding CLS-compliant alternatives.
Attributes that are applied to assemblies or modules must occur after the using clauses and before the code.
For more information about using attributes, see Extending Metadata Using Attributes.
NOTE: The current Microsoft Visual Basic compiler intentionally does not generate a CLS-compliance warning, however, a future release of the compiler will issue that warning.
The following example applies a CLSCompliantAttribute to the entire assembly. using System;
[ assembly:CLSCompliant ( true ) ]
The following declaration generates a CLS-compliance warning because the type UInt32
is not specified in the CLS.
public int SetValue ( UInt32 value );
If the declaration is marked with a CLSCompliantAttribute, no compiler warning or error is generated.
[ CLSCompliant ( false ) ]
public int SetValue ( UInt32 value );
Attribute