4

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

Abdullah Saleem
  • 3,701
  • 1
  • 19
  • 30

1 Answers1

4

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

Abdullah Saleem
  • 3,701
  • 1
  • 19
  • 30