Mark assemblies with ComVisible (deprecated)

Rule ND2202 .NET Framework Usage / System

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

ComVisibleAttribute determines how COM clients access managed code; assemblies should indicate COM visibility explicitly (absent = visible to COM clients), overridable per type and member. Matches assemblies not tagged with System.Runtime.InteropServices.ComVisibleAttribute.

How to fix

Tag the assembly with ComVisibleAttribute, value false if it shouldn't be visible to COM clients.

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 ComVisible (deprecated)</Name>
// <Id>ND2202:MarkAssembliesWithComVisible</Id>

warnif count > 0 from a in Application.Assemblies where 
  !a.HasAttribute ("System.Runtime.InteropServices.ComVisibleAttribute".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.
//
// **ComVisibleAttribute** determines how COM clients access managed code;
// assemblies should indicate COM visibility explicitly (absent = visible to
// COM clients), overridable per type and member. Matches assemblies not
// tagged with **System.Runtime.InteropServices.ComVisibleAttribute**.
//</Desc>

//<HowToFix>
// Tag the assembly with *ComVisibleAttribute*, value **false** if it
// shouldn't be visible to COM clients.
//</HowToFix>

.NET Framework Usage / System: all 12 items