仅保留使用的类型并删除未使用的类型 [英] Only keep used types and remove unused types
问题描述
有什么方法可以从项目中删除未使用的类型/代码.
可以说我在控制台应用程序中使用NAudio
(源代码),而仅使用其中的WaveIn
类.我有什么办法可以从代码中删除未使用的类,而仅保留WaveIn
类,而WaveIn
类取决于?摇晃的树下的东西
Is there any way to remove unused types/code from a project.
lets say I'm using NAudio
(source code) in my console application and I'm only using the WaveIn
class from it. Is there any way for me to remove unused classes from the code and only keep the WaveIn
class and the classes WaveIn
depends upon? Something down the line of tree shaking
推荐答案
Ndepend是答案
Ndepend was the answer
from t in Types
let depth0 = t.DepthOfIsUsedBy("NAudioTrim.Program")
where depth0 >= 0 orderby depth0
select new { t, depth0 }
其中NAudioTrim.Program
包含我的应用程序的入口点,并包含使用的类型.
获取所有使用的类型及其使用的类型的列表后,您可以删除其余文件/类型
where NAudioTrim.Program
contains the entry point of my application and contains the used types.
Once you get the list of all used types and the types they use you can delete the rest of the files/types
这篇关于仅保留使用的类型并删除未使用的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!