codecadwallader / codemaid

CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.
http://www.codemaid.net
GNU Lesser General Public License v3.0
1.88k stars 353 forks source link

Using statements re-insert does not respect "Preferred 'using' directive placement" setting #1003

Open Norazan opened 1 year ago

Norazan commented 1 year ago

Environment

Description

When CodeMaid re-inserts the using statements specified in the settings after a cleanup, it will always place them at the top of the file. Visual Studio has a setting that specifies the preferred 'using' directive placement, for example inside the namespace. It would be nice if CodeMaid can respect this setting.

Steps to recreate

  1. Set the Preferred 'using' directive placement setting to "Inside namespace". This setting can be found in Options -> Text Editor -> C# -> Code Style -> General -> 'using' preferences
  2. In the CodeMaid options under Cleaning -> Visual Studio, add some usings to re-insert when removed.
  3. Create a new C# class and add the usings specified in the previous step (make sure they are unused)
  4. Run a CodeMaid cleanup

Current behavior

The unused usings are re-inserted at the top of the file even though the Preferred 'using' directive placement setting specifies otherwise.

Expected behavior

The unused usings are re-inserted at the location as specified by the Preferred 'using' directive placement setting.

codecadwallader commented 1 year ago

Thanks for the suggestion, I can confirm this is not currently supported.