Mark assemblies with CLSCompliant (deprecated)

Rule ND2201 .NET Framework Usage / System

Deprecated, disabled by default; re-enable if it fits your environment.

The Common Language Specification (CLS) defines rules assemblies must follow for cross-language use. Assemblies should explicitly indicate CLS compliance with CLSCompliantAttribute (absent = not compliant); a compliant assembly may still contain non-compliant members. Matches assemblies not tagged with System.CLSCompliantAttribute.

How to fix

Tag the assembly with CLSCompliantAttribute. Rather than marking the whole assembly non-compliant, mark the specific non-compliant members, ideally providing CLS-compliant alternatives for the widest audience.

CQLinq source

This rule is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.

// <Name>Mark assemblies with CLSCompliant (deprecated)</Name>
// <Id>ND2201:MarkAssembliesWithCLSCompliant</Id>

warnif count > 0 from a in Application.Assemblies where 
  !a.HasAttribute ("System.CLSCompliantAttribute".AllowNoMatch())
select new {
   a,
   Debt = 5.ToMinutes().ToDebt(),
   Severity = Severity.Medium
}

//<Expl>
// The *{0}* should be tagged with *CLSCompliantAttribute*.
//</Expl>

//<Desc>
// Deprecated, disabled by default; re-enable if it fits your environment.
//
// The *Common Language Specification* (CLS) defines rules assemblies must
// follow for cross-language use. Assemblies should explicitly indicate CLS
// compliance with **CLSCompliantAttribute** (absent = not compliant); a
// compliant assembly may still contain non-compliant members. Matches
// assemblies not tagged with **System.CLSCompliantAttribute**.
//</Desc>

//<HowToFix>
// Tag the assembly with *CLSCompliantAttribute*. Rather than marking the
// whole assembly non-compliant, mark the specific non-compliant members,
// ideally providing CLS-compliant alternatives for the widest audience.
//</HowToFix>

.NET Framework Usage / System: all 12 items