Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

with VS 17.8 usings are not cleaned up anymore #1026

Open
bertschmid opened this issue Nov 16, 2023 · 8 comments
Open

with VS 17.8 usings are not cleaned up anymore #1026

bertschmid opened this issue Nov 16, 2023 · 8 comments

Comments

@bertschmid
Copy link

bertschmid commented Nov 16, 2023

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

@antonioatom
Copy link

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

@codecadwallader
Copy link
Owner

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.

@tfadler
Copy link

tfadler commented Dec 20, 2023

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.

@lxman
Copy link

lxman commented Feb 13, 2024

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.

@tfadler
Copy link

tfadler commented Feb 13, 2024

@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

@bertschmid
Copy link
Author

Same problem in 17.9.0

@negatedx
Copy link

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.

@Thomathan
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants