Mark assemblies with CLSCompliant (deprecated)
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.
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>
Open in the interactive Rules Explorer · All default rules
.NET Framework Usage / System: all 12 items
- Mark ISerializable types with SerializableAttribute ND2200
- Mark assemblies with CLSCompliant (deprecated) ND2201
- Mark assemblies with ComVisible (deprecated) ND2202
- Mark attributes with AttributeUsageAttribute ND2203
- Remove calls to GC.Collect() ND2204
- Don't call GC.Collect() without calling GC.WaitForPendingFinalizers() ND2205
- Enum Storage should be Int32 ND2206
- Do not raise too general exception types ND2207
- Do not raise reserved exception types ND2208
- Uri fields or properties should be of type System.Uri ND2209
- Types should not derive from System.ApplicationException ND2210
- Don't Implement ICloneable ND2211