codemaid icon indicating copy to clipboard operation
codemaid copied to clipboard

with VS 17.8 usings are not cleaned up anymore

Open bertschmid opened this issue 2 years ago • 14 comments

Environment

  • Visual Studio version: 2022 Enterprise 17.8
  • CodeMaid version: 12.0.300
  • Code language: C#

Description

with VS 17.8 usings are not cleaned up anymore

Options Cleaning Visual Studio

Run format document -> enaled Run Remove and sort using statements -> enabled

Steps to recreate

  1. Create new class file
  2. Cleanup Active Document

Current behavior

No using are removed that are not used

Expected behavior

unused using are removed

bertschmid avatar Nov 16 '23 08:11 bertschmid

Same issue here. As a workaround you can enable Clean Up Code on save from VS (Options -> Text Editor -> Code Clean Up) and setup a profile with just that setting

image

antonioatom avatar Nov 23 '23 08:11 antonioatom

Thanks for reporting the issue. I have not been able to reproduce it with Visual Studio v17.9 (preview) so I think they may have resolved this already.

codecadwallader avatar Nov 24 '23 18:11 codecadwallader

Myself and members on my team are seeing the issue.

If is fixed in 17.9 preview then they have not rolled it into 17.8.3.

tfadler avatar Dec 20 '23 21:12 tfadler

I've found that this issue (in the latest VS2022) is connected to a file having an extra cr/lf at the end of the file. If I run Codemaid cleanup it will delete the extra cr/lf but then will not clean the usings. I have to run it a second time in order to clean the usings.

lxman avatar Feb 13 '24 16:02 lxman

@lxman is right. I just verified.

I had to do the following to stop VS from adding the final new line.

  1. In my editorconfig set insert_final_newline to false
  2. In my Codemaid options. Cleaning ->Insert-> uncheck Insert end of file trailing new line.

Once I did those, if I double saved my usings would clean.

The first save removing the final newline and the second cleaning the usings.

@codecadwallader now that we have more recreation can you try?

Note this is still a problem with Visual Studio 17.9.0

tfadler avatar Feb 13 '24 21:02 tfadler

Same problem in 17.9.0

bertschmid avatar Feb 15 '24 13:02 bertschmid

Following on from the comments of @tfadler I found that if I disable "Insert end of file trailing new line" and "Insert blank line padding after > using statement blocks" it cleans up using statements on the first attempt.

negatedx avatar Feb 21 '24 23:02 negatedx

Hi @codecadwallader, I was wondering if there's any update to this since reproduction steps and work arounds were provided.

Thomathan avatar Feb 29 '24 18:02 Thomathan

Problem still exists in 17.10.1

bertschmid avatar Jun 11 '24 11:06 bertschmid

And in 17.10.3. There are no extra new line at the end of my code, so that does not seem relevant.

GreenleafDk avatar Jun 22 '24 08:06 GreenleafDk

Same for me in 17.10 and 17.11 preview 9 I found out that I had some kind of conflict between my .editorconfig (insert_final_newline = true) and CodeMaid default behavior (Cleaning/Remove/Remove enf of file trailing new line) By unticking "Remove enf of file trailing new line" in CodeMaid's options, the unused usings starts getting cleaned up again on save 👍

Necriis avatar Aug 13 '24 13:08 Necriis