为什么NDepend在命令行上运行时显示CQL错误,而不是从GUI运行?

时间:2013-07-19 13:43:56

标签: static-analysis ndepend cqlinq

我有一点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

在GUI中没问题,但是当我从命令行运行它时,我在输出报告中收到此消息:

1 query syntax error: Not a valid type name {"System.Attribute"}

知道为什么吗?

1 个答案:

答案 0 :(得分:1)

必须来自mscorlib(包含System.Attribute的程序集)在分析时未解析的事实。您是否在同一台计算机上运行GUI和命令行版本?要查看程序集解析,请转到 NDepend项目属性&gt;要分析的代码,并通过展开文件夹面板来查看解决mscorlib的位置。