JetBrains Rider 2022.2 Help

Code Inspection: Use preferred namespace body style

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, JetBrains Rider lets you configure your preferences and maintain the consistency of your preferences throughout your codebase.

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

using System; namespace MyNamespace { class MyClass { } }
namespace MyNamespace; using System; class MyClass { }
Last modified: 12 November 2021