Events
17 Mar, 21 - 21 Mar, 10
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Property | Value |
---|---|
Rule ID | CA1014 |
Title | Mark assemblies with CLSCompliantAttribute |
Category | Design |
Fix is breaking or non-breaking | Non-breaking |
Enabled by default in .NET 9 | No |
An assembly does not have the System.CLSCompliantAttribute attribute applied to it.
The Common Language Specification (CLS) defines naming restrictions, data types, and rules to which assemblies must conform if they will be used across programming languages. Good design dictates that all assemblies explicitly indicate CLS compliance with CLSCompliantAttribute. If the attribute is not present on an assembly, the assembly is not compliant.
It is possible for a CLS-compliant assembly to contain types or type members that are not compliant.
To fix a violation of this rule, add the attribute to the assembly. Instead of marking the whole assembly as noncompliant, you should determine which type or type members are not compliant and mark these elements as such. If possible, you should provide a CLS-compliant alternative for noncompliant members so that the widest possible audience can access all the functionality of your assembly.
Do not suppress a warning from this rule. If you do not want the assembly to be compliant, apply the attribute and set its value to false
.
If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.
#pragma warning disable CA1014
// The code that's violating the rule is on this line.
#pragma warning restore CA1014
To disable the rule for a file, folder, or project, set its severity to none
in the configuration file.
[*.{cs,vb}]
dotnet_diagnostic.CA1014.severity = none
For more information, see How to suppress code analysis warnings.
The following example shows an assembly that has the System.CLSCompliantAttribute attribute applied that declares it CLS-compliant.
[assembly:CLSCompliant(true)]
namespace DesignLibrary {}
<assembly:CLSCompliant(true)>
Namespace DesignLibrary
End Namespace
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
17 Mar, 21 - 21 Mar, 10
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register now