I am using Visual Studio 2022 to create a C# based project. I would like to format and cleanup my file every time I save a file.
Most instructions states that I should be able to achieve that by going to
"Tools" > "Options" > "Text Editor" > "Code Cleanup". Add a check in the "Run Code Cleanup profile on Save." Be sure to select the appropriate profile you want to execute automatically whenever you save!
The source of the instructions can be found
If you want to to auto apply the rule csharp_style_namespace_declarations = file_scoped to a code profile, you can refer to this link to edit the .editorconfig file. https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2022
You can see the Example .editorconfig file from here: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#namespace-options
[*.cs]
csharp_style_namespace_declarations = file_scoped