I've got this bit of CQL:
// <Name>A stateless class or structure might be turned into a static type</Name>
warnif count > 0 (from t in Application.Types where
t.SizeOfInst ==0 &&
// For accuracy, this constraint doesn't take
// account of types that implement some interfaces.
// and classes that have a base class and don't
// derive directly from System.Object, or classes
// that have sub-classes children.
t.NbInterfacesImplemented == 0 &&
((t.IsClass && t.DepthOfInheritance == 1
&& t.NbChildren == 0)
|| t.IsStructure) &&
!t.IsStatic &&
!t.DeriveFrom("System.Attribute") &&
!t.IsAttributeClass &&
!t.IsGeneric && t.Name!="Program" && !(t.IsGeneratedByCompiler || t.HasAttribute(@"NDepend.CQL.NDependIgnoreAttribute") || t.HasAttribute("System.Runtime.CompilerServices.CompilerGeneratedAttribute".AllowNoMatch()))
select new { t, t.SizeOfInst, t.NbInterfacesImplemented,
t.DepthOfInheritance, t.NbChildren }).Take(10)
// this rule indicates stateless types that might
// eventually be turned into static classes.
// See the definition of the SizeOfInst metric here
// http://www.ndepend.com/Metrics.aspx#SizeOfInst
It's fine in the GUI, but I get this message in the output report when I run it from the command line:
1 query syntax error: Not a valid type name {"System.Attribute"}
Any idea why?
It must come from the fact that
mscorlib
, the assembly that containsSystem.Attribute
, is not resolve at analysis time. Are you running GUI and command line versions on the same machine? To look at assembly resolving go to NDepend Project Properties > Code to Analyze and see from wheremscorlib
is resolved by unfolding the folder panel.