ReSharper for Visual Studio Code 2026.1 Help

Code syntax style: file-scoped namespaces

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.

ReSharper helps you enforce preferences for file-scoped namespaces in the existing code and takes your preferences into account when it produces new code with code completion and performs refactorings.

Enforce preferences for file-scoped namespaces

ReSharper can help you check single namespaces in your files for compliance with your preferences and if they do not comply, it highlights such declarations and suggests the corresponding quick-fix. Default ReSharper's preferences say that file-scoped namespaces are preferred.

However, you can configure your preferences in a different way, so that ReSharper suggests making existing file-scoped namespaces block-scoped:

ReSharper. 'To block-scoped namespace' quick-fix

Configure preferences for file-scoped namespaces

You can configure syntax style settings via EditorConfig. These settings can be stored in .editorconfig files on different levels of your solution hierarchy. The files are normally put under VCS so that settings defined there are shared among the project team.

If you have used ReSharper for Visual Studio or JetBrains Rider on your computer, or have opened the current solution using these tools, ReSharper for Visual Studio Code will read and apply your syntax style settings from .DotSettings files. However, any settings configured via .editorconfig will take precedence.

Configure preferences for namespace declaration style using EditorConfig

  1. Open the desired .editorconfig file.

  2. Add the required namespace declaration style properties to the file. For example:

    namespace_body = file_scoped
03 March 2026