My Homepage

CLS Compliant Attribute

 CLS Compliant Attribute (Class)

 .NET Framework 4.5 Other Versions This topic has not yet been rated - Rate this topic

Indicates whether a program element conforms to the Common Language Specification (CLS). This class can not be inherited.

Inheritance Hierarchy

System.Object

   System.Attribute

     System.CLSCompliantAttribute

Namespace: System

Assembly: mscorlib (in mscorlib.dll)

syntax

 F C # C # VB ++

[SerializableAttribute]

[AttributeUsageAttribute (AttributeTargets.All, Inherited = true, allowMultiple = false)]

[ComVisibleAttribute (true)]

public sealed class CLSCompliantAttribute: Attribute

The CLSCompliantAttribute type exposes the following members.

Builders

 Show: Inherited Protected

  name Description

PúblicoCompatible method XNA FrameworkCompatible with portableCompatible Library .NET classes for Shop Windows applications CLSCompliantAttribute Initializes an instance of the class CLSCompliantAttribute a Boolean value that indicates whether the element specified program complies with CLS.

above

properties

 Show: Inherited Protected

  name Description

Property públicaCompatible XNA FrameworkCompatible with portableCompatible Library .NET classes for Shop Windows applications IsCompliant Gets the Boolean value that indicates whether the element specified program complies with CLS.

Public property TypeId When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)

above

methods

 Show: Inherited Protected

  name Description

PúblicoCompatible method XNA FrameworkCompatible with portableCompatible Library .NET classes for Shop Windows applications Equals Infrastructure. Returns a value that indicates whether this instance is equal to the specified object. (Inherited from Attribute.)

PúblicoCompatible method XNA FrameworkCompatible with portableCompatible Library .NET classes for Shop Windows applications GetHashCode Returns the hash code for this instance. (Inherited from Attribute.)

PúblicoCompatible method XNA FrameworkCompatible with portableCompatible Library .NET classes for Shop Windows applications GetType Gets the Type of the current instance. (Inherited from Object.)

Public method IsDefaultAttribute When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)

PúblicoCompatible method XNA Framework Match When overridden in a derived class, returns a value that indicates whether this instance is equal to the specified object. (Inherited from Attribute.)

PúblicoCompatible method XNA FrameworkCompatible with portableCompatible Library .NET classes for Windows applications ToString Returns a string that represents the current object store. (Inherited from Object.)

above

Explicit interface implementations

 Show: Inherited Protected

  name Description

Implementation explicit private interfacesMétodo _Attribute.GetIDsOfNames Maps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)

Implementation explicit private interfacesMétodo _Attribute.GetTypeInfo Gets the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)

Implementation explicit private interfacesMétodo _Attribute.GetTypeInfoCount

Retrieves the number of type information interfaces that an object provides (either 0 or 1)

(Inherited from Attribute.)

Implementation explicit private interfacesMétodo _Attribute.Invoke Provides access to properties and methods exposed by an object. (Inherited from Attribute.)

above

Reviews

 The CLSCompliantAttribute attribute is used to indicate whether a program meets certain element Specification (CLS), which defines the characteristics that any language directed .NET Framework must satisfy. Compatibility with CLS serves mainly concern libraries programmers who want to ensure that their libraries are accessible in any language directed .NET Framework. For more information, see Independence of language and language independent components.

The CLSCompliantAttribute attribute can be applied to the following program elements: assembly, module, class, struct, enum, constructor, method, property, field, event, interface, delegate, parameter and return value. However, under the notion of CLS is only meaningful for assemblies, modules, types and members of types and not for the elements of a member firm. Therefore omitted CLSCompliantAttribute when applied to program elements or return value parameter.

If no CLSCompliantAttribute is applied to a program element, by default:

The assembly does not conform to CLS.

The type conforms to CLS only if the enclosing type or assembly is CLS compliant.

The member of a type conforms to CLS only if the type conforms to CLS.

If an assembly is marked as CLS under, any publicly exposed the assembly that does not conform to CLS must be marked with CLSCompliantAttribute using a false argument. Similarly, if a class is marked as CLS, shall be marked one by one all the members who do not conform to CLS. All non-compliant members must provide alternatives in accordance with CLS.

The attributes that apply to assemblies or modules must occur after using clauses in C # (Imports in Visual Basic) and before the code.

For more information about using attributes, see Extending Metadata Using Attributes.

NoteNote

The current Microsoft Visual Basic compiler generates a warning unintentionally under CLS, however, a future version of the compiler will issue a warning.

Examples

 In the following example, CLSCompliantAttribute applies to the entire assembly.

using System;

     [assembly: CLSCompliant (true)]

The following statement generates a warning in accordance with CLS because the UInt32 type is not specified in CLS.

  public int SetValue (UInt32 value);

If the statement is marked with a CLSCompliantAttribute, no compiler warning or error is generated.

[CLSCompliant (false)]

  public int SetValue (UInt32 value);

Version Information

 .NET Framework

Compatible with: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Compatible with: 4, 3.5 SP1

Portable library classes

Compatible with: portable library classes

.NET Applications Shop Windows

Compatible with: Windows 8

.NET Windows Phone Applications

Compatible with: Windows Phone 8, Silverlight 8.1

platforms

 Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role is not supported), Windows Server 2008 R2 (supported Server Core Role with SP1 or later; Itanium not supported)

.NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System.

Thread Safety

 Any public static (Shared in Visual Basic) members of this type are safe for the thread. No guarantees that instance members are safe for the thread.

This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free