views:

14

answers:

1

I frequently use the "Remove and sort usings" feature of VS/PowerCommands - in fact, with the help of R#, I make VS do this for me every time i save the document, which I almost reflexively do almost every time I finish writing a code line without errors.

However, there are a couple of namespaces that, if they are there, I don't want to remove.

Mainly, this concerns System, System.Linq and System.Web.Collections.Generic, but there are others too, and the specification of exactly which namespaces are concerned will likely change in the future.

Is there any way to tell this feature that "If you see this or that namespace and it's not used at the moment, never mind. I'll remove it manually."?

A: 

There is no way. You could write your own visual studio extension but I don't know the reason to do that. If it is because you don't like to write using lines you can use the alt+shift+f10 shortcut that it writes it for you.

Victor Marzo
The problem is mainly that namespaces that mostly/only contain extension methods are removed when those aren't in use, and to import them again I first need to type one out, spelled correctly and with the correct case, and then let R# do the importing for me. Since I usually press Save before I've used for example any of the LINQ extensions on IEnumerable, I have to manually import System.Linq before they're in Intellisense. Mighty annoying.
Tomas Lycken