codemaid icon indicating copy to clipboard operation
codemaid copied to clipboard

Using statements to re-insert being ignored

Open stephenhynds opened this issue 11 years ago • 6 comments

I have two using statements I want to re-insert any time the code is cleaned on save. I've gone into Cleaning -> Visual Studio and checked Run remove using statements, and in the re-insert box I have: using System; using System.Linq;

But when I save it doesn't respect either of the statements to be re-inserted.

stephenhynds avatar May 11 '15 09:05 stephenhynds

By default, using statements are not removed (or re-inserted) during cleanup on save unless you disable the defaulted option "Skip during automatic cleanup on save" which is indented within the "Run remove unused using statements" option. This is off by default as it can cause conflicts with other tools.

If that doesn't resolve the issue, please provide an export of your settings.

codecadwallader avatar May 11 '15 10:05 codecadwallader

Thanks for the reply. Settings available here - https://www.dropbox.com/s/160z2er87a0ehgy/CodeMaid.settings?dl=0

I have Run remove unused using statements checked, and skip is unchecked.

stephenhynds avatar May 11 '15 11:05 stephenhynds

Sorry, hit the wrong button there!

stephenhynds avatar May 11 '15 11:05 stephenhynds

Thanks for providing your settings. Those look correct to me, and work as expected for me. Here's a sample code file:

using System;

using System.Linq;

namespace SpecificIssues
{
    internal class Issue100
    {
    }
}

Note: This feature is for "Using statements to re-insert when removed". It will not add those using statements if they were not already present.

Can you provide a code sample that isn't working as expected?

Also, please note there is a known related issue with #87 about multiple statements including a blank line between them with the latest beta.

codecadwallader avatar May 12 '15 22:05 codecadwallader

Steve, I'm a total idiot and I've wasted your time! I've just realised that I had the VS Productivity Power Tools installed, and it also has a format and remove using statements function which was overriding codemaid. I've disabled that and lo and behold it's now working as it should be.

stephenhynds avatar May 13 '15 14:05 stephenhynds

No worries, glad you got it figured out.

codecadwallader avatar May 13 '15 15:05 codecadwallader