When I write C#, I sometimes have 3-4 missing usings which I can add with the tooltip window -> add missing using, or doing ctrl + . On the line where a missing using is present.
Doing this 3-4 times is rather annoying.
I have noticed a "add all missing usings" tooltip sometimes, which worked, but I can not get it to pop up reliably.
I know resharper has it, but I don't want to use a paid extension for this feature.
How can I reliably get this "add all missing usings" pop up, or in what other way can I add all missing usings at once?
Thanks!
The "add missing usings" is triggered by a paste action. After you paste new code, the option will be available so long as you haven't made any edits to the document after pasting the code (making any edit removes the option). Also, the option doesn't add missing usings for the rest of the document -it only analyzes the pasted section-.
You can cut out your code and then paste it to trigger the action as unfortunately currently it is not part of the default Quick Actions refactorings.
To complete @rhytonix answer... after pasting your code, you have to click on the screwdriver in the left margin like this:
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