Reputation: 1856
I clicked "Find Code Issues", then Resharper showed me list of unused classes and methods. But I can't find how to automatically remove all them. List of unused classes and methods contains thousands of lines, so сlicking on each line and delete method manually is not real. How to do it automatically?
I tried to use "Code Cleanup", but it doesn't remove unused classes and methods
The version of Resharper: JetBrains ReSharper 8.2.1 Full Edition Build 8.2.1000.4556 on 2014-05-19T09:12:38
Upvotes: 7
Views: 4618
Reputation: 544
Unfortunately Resharper does not provide this feature as it can be unsafe.
To partially automate the deletion you can try installing AutoHotkey. This program will allow you to automate the entry of hotkeys and therefore 'automate' repetitive Resharper tasks like deleting unused code detected by Code Issues.
The following script automatically goes to the next code issue and attempts to 'Safely Delete'. If this takes too long it cancels it with {Escape} as this is generally means Resharper has found a conflict or usage.
#d::
Loop {
Send !{Del}
Sleep, 500
Send {Enter}
Sleep, 1000
Send {Escape}
Sleep, 500
Send {F8}
Sleep, 500
}
Return
To use this script click on the first item under the Type Or Member is Never Used category then hit the Win-D hot key. The script will then cycle through all the issues deleting the methods which do not have conflicts. To break the loop select outside of Visual Studio & Reload the script.
If you remove the Loop & {Escape} then you can use this as a single shortcut to delete & move to the next issue.
Upvotes: 6