ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Code inspection: Use preferred namespace body style

Last modified: 08 April 2024

Starting from C# 10, you can use file-scoped namespace declarations in files containing a single namespace.

If you prefer to stick to either file-scoped or block-scoped namespace declarations, ReSharper lets you configure your preferences and maintain the consistency of your preferences throughout your codebase.

For example, if you prefer having file-scoped namespaces, ReSharper suggests the quick-fix To file-scoped namespace if there is a single namespace declaration in a file.