Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
180 lines (161 sloc) 10.7 KB
<Type Name="CLSCompliantAttribute" FullName="System.CLSCompliantAttribute">
<TypeSignature Language="C#" Value="public sealed class CLSCompliantAttribute : Attribute" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi serializable sealed beforefieldinit CLSCompliantAttribute extends System.Attribute" />
<TypeSignature Language="DocId" Value="T:System.CLSCompliantAttribute" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class CLSCompliantAttribute&#xA;Inherits Attribute" />
<TypeSignature Language="C++ CLI" Value="public ref class CLSCompliantAttribute sealed : Attribute" />
<TypeSignature Language="F#" Value="type CLSCompliantAttribute = class&#xA; inherit Attribute" />
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.0.20.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Attribute</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute FrameworkAlternate="netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netstandard-1.0;netstandard-1.1;netstandard-1.2;netstandard-1.3;netstandard-1.4;netstandard-1.5;netstandard-1.6;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8;netcore-2.2;dotnet-uwp-10.0;netcore-3.0;netstandard-2.1">
<AttributeName>System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=false, Inherited=true)</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>System.Runtime.InteropServices.ComVisible(true)</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0">
<AttributeName>System.Serializable</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Indicates whether a program element is compliant with the Common Language Specification (CLS). This class cannot be inherited.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.CLSCompliantAttribute> attribute is used to indicate whether a particular program element complies with the Common Language Specification (CLS), which defines the features that any language that targets the .NET Framework must support. CLS compliance is primarily of concern to library developers who want to ensure that their libraries are accessible in any language that targets the .NET Framework. For more information, See [Language Independence and Language-Independent Components](~/docs/standard/language-independence-and-language-independent-components.md).
You can apply the <xref:System.CLSCompliantAttribute> attribute to the following program elements: assembly, module, class, struct, enum, constructor, method, property, field, event, interface, delegate, parameter, and return value. However, the notion of CLS compliance is only meaningful for assemblies, modules, types, and members of types, not parts of a member signature. Consequently, <xref:System.CLSCompliantAttribute> is ignored when applied to parameter or return value program elements.
If no <xref:System.CLSCompliantAttribute> is applied to a program element, then 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 of a type is CLS-compliant only if the type 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 <xref:System.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 C# `using` (`Imports` in Visual Basic) clauses and before the code.
For more information about using attributes, see [Attributes](~/docs/standard/attributes/index.md).
> [!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.
## Examples
The following example applies a <xref:System.CLSCompliantAttribute> to the entire assembly.
```csharp
using System;
[assembly: CLSCompliant(true)]
```
The following declaration generates a CLS-compliance warning because the type `UInt32` is not specified in the CLS.
```csharp
public int SetValue(UInt32 value);
```
If the declaration is marked with a <xref:System.CLSCompliantAttribute>, no compiler warning or error is generated.
```csharp
[CLSCompliant(false)]
public int SetValue(UInt32 value);
```
]]></format>
</remarks>
<altmember cref="T:System.Attribute" />
<related type="Article" href="https://msdn.microsoft.com/library/4f0b77d0-4844-464f-af73-6e06bedeafc6">Language Independence and Language-Independent Components</related>
<related type="Article" href="~/docs/standard/attributes/index.md">Extending Metadata Using Attributes</related>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public CLSCompliantAttribute (bool isCompliant);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(bool isCompliant) cil managed" />
<MemberSignature Language="DocId" Value="M:System.CLSCompliantAttribute.#ctor(System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (isCompliant As Boolean)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; CLSCompliantAttribute(bool isCompliant);" />
<MemberSignature Language="F#" Value="new CLSCompliantAttribute : bool -&gt; CLSCompliantAttribute" Usage="new System.CLSCompliantAttribute isCompliant" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.0.20.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="isCompliant" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="isCompliant">
<see langword="true" /> if CLS-compliant; otherwise, <see langword="false" />.</param>
<summary>Initializes an instance of the <see cref="T:System.CLSCompliantAttribute" /> class with a Boolean value indicating whether the indicated program element is CLS-compliant.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="IsCompliant">
<MemberSignature Language="C#" Value="public bool IsCompliant { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool IsCompliant" />
<MemberSignature Language="DocId" Value="P:System.CLSCompliantAttribute.IsCompliant" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property IsCompliant As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property bool IsCompliant { bool get(); };" />
<MemberSignature Language="F#" Value="member this.IsCompliant : bool" Usage="System.CLSCompliantAttribute.IsCompliant" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.0.20.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the Boolean value indicating whether the indicated program element is CLS-compliant.</summary>
<value>
<see langword="true" /> if the program element is CLS-compliant; otherwise, <see langword="false" />.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.