We have a 10+ years old ASP.NET website project, with lots of unused / legacy user controls and pages.
Is there a tool which can assist in the process of identifying these elements of the solution, so we could refactor them out?
I know the issue is complicated because not all types are referenced as types which a compiler / tool might recognize. e.g. objects instantiated by reflection are instantiated using a string representing the class name. In addition asp.net pages are generally not referenced as types, but as page identifier strings in markup.
It still seems like someone would have created a tool which handles these cases and creates a candidate list of unused classes / pages / user controls
You may use this regex to find unused registered controls
<%@\s*Register\s+TagPrefix\s*=\s*"(?<tagprefix>[^"]+)"\s+TagName\s*=\s*"(?<tagname>[^"]+)"\s+Src\s*=\s*"[^"]+"\s*%>(?!.*?\k<tagprefix>:\k<tagname>\s+)
I used powergrep to run this regex. The "Dot matches newline" checkbox should be enabled to work properly.
ReSharper is a refactoring tool which might help you to identify clouds of unused classes and methods. It can also delete them safely. It allows you to delete a method or class and adjust all it's usages. See: Safe delete
It has also appropriate support of ASP.NET. See: ASP.NET support
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