【问题标题】:Why does NDepend show CQL errors when run on the command line but not from the GUI?为什么 NDepend 在命令行上运行而不是从 GUI 运行时显示 CQL 错误?
【发布时间】:2013-07-19 13:43:56
【问题描述】:

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

知道为什么吗?

【问题讨论】:

  • Steven 我的回答是否有助于解决您提到的问题?如果它是我们产品中的错误,我们希望修复它,但到目前为止我们无法重现它。谢谢
  • 嗨@PatrickfromNDependteam。感谢您的回答(我在您发布时投了赞成票),但我还没有机会验证它。当我这样做时,我会告诉你。感谢您的跟进,非常感谢。

标签: static-analysis ndepend cqlinq


【解决方案1】:

这一定是因为包含System.Attribute 的程序集mscorlib 在分析时没有解析。您是否在同一台机器上运行 GUI 和命令行版本?要查看程序集解析,请转到 NDepend 项目属性 > 要分析的代码,然后通过展开文件夹面板查看 mscorlib 的解析位置。

【讨论】:

    猜你喜欢
    • 2021-02-28
    • 1970-01-01
    • 2012-02-14
    • 1970-01-01
    • 2021-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多