Remove unused using directives

Hello,

I want Rider to remove unused 'using' directives in my code. So I went to settings Editor -> Code Cleanup made a copy of the "Built-in: Reformat Code" profile and then checked C# -> Optimize 'using' directives -> Optimize 'using' directives and also set that profile as default for silent cleanup. But still rider doesn't seem to care...

Anything else I need to do?

Thank you

3
5 comments

Hi Marco! 

You can use `Code | Optimize imports` for this purpose. Could you check it? 

If you request is more about silent code cleanup, could you please clarify your Rider version (`Help | About` or `JetBrains Rider | About`) and the type of your project? 

2

Hi Alexandra

Yes that's what I'm looking for. Is it possible to perform this action together with "Reformat Code"?

Thank You

1

Hi Marco! 

Could you please clarify, you call Editor -> Silent Code Cleanup with your custom profile set ad default? What happens instead? What Rider version do you use? Thank you. 

1

I can confirm that this is also not working for me (optimize imports silently). Rider version: Rider 2022.1.2

0

Electrobuddha, thank you for your question. Does the problem happen for a newly created solution or it's solution specific problem?

Could you please collect all Rider `.DotSettings` files:

- *Personal layer*: ```.DotSettings.user``` file near your sln (if any)
- *Team-shared layer*: ```.DotSettings``` file near your sln (if any)
- *Global settings layer*: Use "Help -> Diagnostic tools -> Special Files and Folders -> R# Global Settings" to locate ```GlobalSettingsStorage.DotSettings``` file

Then please use the "Submit a request" button at the top of the page and attach the resulting files to the request. Thanks in advance!

0

Please sign in to leave a comment.