Abdullah Saleem
Abdullah Saleem

Reputation: 3811

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

Upvotes: 4

Views: 660

Answers (1)

Abdullah Saleem
Abdullah Saleem

Reputation: 3811

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

Upvotes: 4

Related Questions