在NDepend中获取程序集元数据

时间:2013-09-25 11:41:00

标签: ndepend

我正在尝试创建CQL查询,它将选择我公司创建的程序集。

在我看来,最简单的方法是检查AssemblyInfo中生成的数据,但我找不到如何在CQL中访问它。

1 个答案:

答案 0 :(得分:0)

代码查询怎么样:

from a in Application.Assemblies
where a.Name.StartsWith("YourCompany.YourProduct")
select a

或者你需要更复杂的东西吗?


好的,从this default rule获取灵感:

// <Name>UI layer shouldn't use directly DB types</Name>
warnif count > 0

// UI layer is made of types in namespaces using a UI framework
let uiTypes = Application.Namespaces.UsingAny(Assemblies.WithNameIn("PresentationFramework", "System.Windows", "System.Windows.Forms", "System.Web")).ChildTypes()

// You can easily customize this line to define what are DB types.
let dbTypes = ThirdParty.Assemblies.WithNameIn("System.Data", "EntityFramework", "NHibernate").ChildTypes()
              // Ideally even DataSet and associated, usage should be forbidden from UI layer: 
              // http://stackoverflow.com/questions/1708690/is-list-better-than-dataset-for-ui-layer-in-asp-net
              .Except(ThirdParty.Types.WithNameIn("DataSet", "DataTable", "DataRow"))

from uiType in uiTypes.UsingAny(dbTypes)
let dbTypesUsed = dbTypes.Intersect(uiType.TypesUsed)
select new { uiType, dbTypesUsed }

当然,集合uiTypesdbTypes必须使用级别N的程序集和级别N + 1的程序集进行细化。