Does Visual Studio 2013 have facility for showing unused functions?
What is the best solution to removing those functions?
To find unused members with a Code Analysis Ruleset, from the Visual Studio menu select File -> New -> File… -> General -> Code Analysis Rule Set. Uncheck all the rules. There are many rules we don't care about right now – and some we probably won't ever care about.
So the linker is able to remove each individual function because it is in its own section. So enabling this for your library will allow the linker to remove unused functions from the library.
ReSharper can detect and highlight dead code when solution-wide analysis is enabled.
It will report some false positives, so a manual review is still needed. For instance, R# won't detect when a function is used only through reflection, and will consider it's not used. The same goes for things like IoC containers based on conventions etc.
JetBrains provides some custom attributes to decorate your code with (like [UsedImplicitly]
). They guide the R# analysis engine and document your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With