VS 2022 – Convert to file-scoped namespace in all files

Adding a rule to use file scoped namespaces in .editorconfig worked for me:

  • create an .editorconfig file in the solution directory
  • add following line/content below (docs, code – IDE0161)

Example .editorconfig file content:

[*.cs]
csharp_style_namespace_declarations = file_scoped:warning

After that the preview changes dialog had an option to apply the fix to the whole project/solution:

enter image description here

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)