如何获取引用的方法(目标)名称空间

时间:2018-07-03 23:01:00

标签: ndepend

我正在使用NDepend 2018.1.1。并且我需要获取以下 NDepend 查询

target的命名空间
//
// <Name>Relevant Methods</Name>
//

let e9 = "Sys.Core.App.CommonService"
let e10 = "Sys.Core.App.CommonService3GProvider"
let e17 = "Sys.Core.App.UnderwritingService3GProvider"
let e18 = "Sys.Core.App.UniquePerson.Actions"
let e19 = "Sys.Core.App.UniquePerson"

let e1 = "Sys.Co.Application.UnderwritingService"
let e2 = "Sys.Co.Application.UnderwritingService3GProvider"

let e3 = "Sys.Core.App.Accounting.Services"
let e4 = "Sys.Core.App.Accounting.Services.Provider"

let e5 = "Sys.Core.App.BillingService"
let e6 = "Sys.Core.App.BillingService3GProvider"


let e7 = "Sys.Core.App.ClaimsService"
let e8 = "Sys.Core.App.ClaimsService3GProvider"

let e11 = "Sys.Core.App.EventsService"
let e12 = "Sys.Core.App.EventsService3GProvider"

let e13 = "Sys.Core.App.IntegrationService"
let e14 = "Sys.Core.App.IntegrationService3GProvider"

let e15 = "Sys.Core.App.SecurityServices"

let e16 = "Sys.Core.App.UnderwritingService"
/**/


let ensamblados = from m in 
         Assemblies.WithName(e1).Concat(
         Assemblies.WithName(e2)).Concat(
         Assemblies.WithName(e3)).Concat(
         Assemblies.WithName(e4)).Concat(
           Assemblies.WithName(e5)).Concat(
           Assemblies.WithName(e6)).Concat(
           Assemblies.WithName(e9)).Concat(
           Assemblies.WithName(e10)).Concat(
           Assemblies.WithName(e11)).Concat(
           Assemblies.WithName(e12)).Concat(
           Assemblies.WithName(e13)).Concat(
           Assemblies.WithName(e14)).Concat(
           Assemblies.WithName(e15)).Concat(
           Assemblies.WithName(e16)).Concat(
           Assemblies.WithName(e17)).Concat(
           Assemblies.WithName(e18)).Concat(
           Assemblies.WithName(e19))

select m

//Obtain the types and members of the assemblies
from dest in ensamblados 
let targets = dest.ChildTypesAndMembers.ToHashSetEx() 

let methodsUser = Application.Methods.UsingAny(targets)
let typesUser = Application.Types.UsingAny(targets)


//Search all the sources that call any of the targets Type or Members

//Concatenar los metodos y los tipos de orig
let results = from orig in methodsUser //.Concat((IEnumerable<IMember>)typesUser)

//这里需要获取以下target的命名空间

select new { 
   orig
   ,t=orig.FullName
   ,NumRefAlOrig = orig.IsMethod ? orig.AsMethod.MethodsCalled.Intersect(targets).Concat(orig.AsMethod.FieldsUsed.Intersect(targets)).Count() : 
             orig.AsType.TypesUsed.Intersect(targets).Count()

   ,OrigenEsMetodo= orig.IsMethod
   ,OrigenTipo= orig.IsMethod ? "Metodo":"Tipo"
}

/*Metodos*/
from rr in results
where rr.OrigenEsMetodo 
select rr

我尝试了与NDepend框架不同的方法,但这是我的第一个NDepende查询,并且我感觉缺少的东西很明显

1 个答案:

答案 0 :(得分:-1)

首先,您可以通过编写来简化

let ensamblados = from m in 
         Assemblies.WithNameIn(
  "Sys.Co.Application.UnderwritingService",
  "Sys.Co.Application.UnderwritingService3GProvider",...)

let ensamblados = from m in 
         Assemblies.WithNameLike("Sys.Co.Application.")
.Concat( Assemblies.WithNameLike("Sys.Core.App.")

当问题更清晰时,我们将完成此答案