Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only keep used types and remove unused types

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

like image 793
Abdullah Saleem Avatar asked Oct 21 '25 04:10

Abdullah Saleem


1 Answers

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

like image 136
Abdullah Saleem Avatar answered Oct 22 '25 18:10

Abdullah Saleem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!