Removed Unused Class is extremely annoying as implemented!

The "Remove Unused Class" item on the bulb drop down menu is, frankly, really pissing me off.

I write lots of new code.  Often when I'm doing initial development of something I'll write a bunch of related classes, interfaces and enums one file because its quicker that way.  Or if I'm making a new polymorphic class I'm likely to code it in the same file as an existing one that is similar.  Once again, this increases efficiency while writing initial code.

The problem is once I've got the initial code written then I want to move the classes into separate files which ReSharper makes very easy.  So I put my cursor on the name of a type I want to move out to its own file, go over to the resharper bulb menu and intend to click the "Move to <something>.cs" but now instead the first item in the menu has become "Remove unused class" which I've just clicked by accident!  This causes an immediate PANIC because I don't want to lose the code I may have just spent HOURS writing!  PANIC!  It does seem to bring up some dialog to do this but I don't care, I don't even want to get into a process that could lead to deleting my code unintentionally.

ReSharper should try very hard to NEVER add something this potentially destructive where the user could easily click it unintentionally.  Something like this should be added to THE BOTTOM OF THE MENU, not as the top item!  I don't at all mind having the option available, but sometimes having it appear where an extremely helpful and non-destructive item usually is causes anxiety.

Pretty much the only thing that causes me anxiety when coding is the possibility of losing work.  Sure I save & save often, but something like this could lead to loss of work.  And I definitely haven't yet checked anything into version control because that can't occur until after I've spit things into separate files.

So please either tell me how I can configure ReSharper so this doesn't happen or modify ReSharper not to have this behavior.  Please note that not having ReSharper identify unused code is not an acceptable configuration option.  Having ReSharper notice unused code and darken it in the UI is extremely useful, I just don't want that dang menu item popping up where I expect something more useful and much more commonly used to be.

3 comments
Comment actions Permalink
Official comment

Hello James,

 

Thank you for the feedback.

I've filed the corresponding request - https://youtrack.jetbrains.com/issue/RSRP-476295.

You are welcome to comment or vote for it.

Thank you.

Comment actions Permalink

Same here. Good lord, Those were some good scares I had today! :-o

I very very much want this to no longer be the first option. I prefer the extract to separate file as the first option. I'm in the impression that used to be the default/top option, because my muscle memory seems to direct me to this now very destructive action.

0
Comment actions Permalink

I completely agree with Koen. Muscle memory in Resharper is very important for me, as the whole point for me to use R# is to increase productivity.

I have already accidentally deleted dozens of just written classes because of this. I personally feel that deletion should _never_ be part of the Actions list, since it cannot be easily undone with ctrl-z, and in some cases not at all. Removal of lines I can accept, but not (indirect) file deletion. Warnings do not work, since we are so used to knowing what the popup-dialog does, we just press enter before reading. I would rather move all deletion/removal functionality to a special context-specific deletion shortcut. Shift-delete works fine for me, and could be expanded to include Remove unused usings, etc.

The way I generally write a new class is: Create interface. Copy empty interface to implementation folder. Rewrite interface to class implementing interface. Alt-Enter->Enter on classname to rename file to class name. I usually do this before adding the interface/implementation to the DI Module, and thus the class is not used yet. When we move to a DI registration mechanism that works on namespace conventions instead of explicit registrations, R# will think that _all_ my injected interface implementations are unused until I make a unit test. This might lead to a lot more accidental deletions for us when we implement that.

0

Please sign in to leave a comment.