Only keep used types and remove unused types

对着背影说爱祢 提交于 2019-12-22 10:57:42

问题


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


回答1:


Ndepend was the answer

from t in Types 
let depth0 = t.DepthOfIsUsedBy("NAudioTrim.Program")
where depth0  >= 0 orderby depth0
select new { t, depth0 }

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



来源:https://stackoverflow.com/questions/38822663/only-keep-used-types-and-remove-unused-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!