1

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

知道为什么吗?

4

1 回答 1

1

它必须来自这样一个事实,mscorlib即包含的程序集System.Attribute在分析时未解析。您是否在同一台机器上运行 GUI 和命令行版本?要查看程序集解析,请转到NDepend Project Properties > Code to Analyzemscorlib并通过展开文件夹面板查看从何处解析。

于 2013-07-20T18:12:03.470 回答