Delete unused operations throughout the assembly

I am wondering if ReSharper can work with every class and delete unused entries? I looked, but I do not see such an option in R # 4.5. Has anyone seen this in Resharper outside of just deleting entries in the same class?

+44
resharper
Feb 25 '10 at 17:04
source share
3 answers

I believe that project cleanup is a new feature in ReSharper 5.

I believe in this, the function is in ReSharper 4.5. If you right-click on a solution, the item "Clear code ..." appears, which allows you to apply a cleanup profile to it. You can create a new cleanup profile from Cleanup node code in the ReSharper options if you want the profile to simply configure using directives.

+37
Feb 25 '10 at 17:13
source share

With Resharper 9, you can simply select the โ€œin solutionโ€ area when cleaning up the block in use.

enter image description here

+63
Feb 02 '15 at 12:42
source share

There is also another way that I found here using macros.

Step 1. Create a new macro in Visual Studio via Tools | menu macro.

Step 2: Paste the code below into the Module and save it

 Public Module Module1 Sub OrganizeSolution() Dim sol As Solution = DTE.Solution For i As Integer = 1 To sol.Projects.Count OrganizeProject(sol.Projects.Item(i)) Next End Sub Private Sub OrganizeProject(ByVal proj As Project) For i As Integer = 1 To proj.ProjectItems.Count OrganizeProjectItem(proj.ProjectItems.Item(i)) Next End Sub Private Sub OrganizeProjectItem(ByVal projectItem As ProjectItem) Dim fileIsOpen As Boolean = False If projectItem.Kind = Constants.vsProjectItemKindPhysicalFile Then 'If this is ac# file If projectItem.Name.LastIndexOf(".cs") = projectItem.Name.Length - 3 Then 'Set flag to true if file is already open fileIsOpen = projectItem.IsOpen Dim window As Window = projectItem.Open(Constants.vsViewKindCode) window.Activate() projectItem.Document.DTE.ExecuteCommand("Edit.RemoveAndSort") 'Only close the file if it was not already open If Not fileIsOpen Then window.Close(vsSaveChanges.vsSaveChangesYes) End If End If End If 'Be sure to apply RemoveAndSort on all of the ProjectItems. If Not projectItem.ProjectItems Is Nothing Then For i As Integer = 1 To projectItem.ProjectItems.Count OrganizeProjectItem(projectItem.ProjectItems.Item(i)) Next End If 'Apply RemoveAndSort on a SubProject if it exists. If Not projectItem.SubProject Is Nothing Then OrganizeProject(projectItem.SubProject) End If End Sub End Module 

Step 3: Run the macro on any solution that you would like and there you have it! Enjoy :)

+4
Apr 15 2018-11-11T00
source share



All Articles