Automatic Namespace Detection and Adjustment
Smart namespace management that automatically determines the correct namespace for new files.
How It Works
When you create a file, the namespace is automatically determined by:
- Project Root Namespace: Read from the .csproj file
- Folder Structure: Relative path from project root
- .NET Conventions: Standard naming patterns
Examples
Project Root
File: MyProject/MyClass.cs
Namespace: MyProject
In Subfolder
File: MyProject/Services/UserService.cs
Namespace: MyProject.Services
Nested Folders
File: MyProject/Features/Auth/Services/AuthService.cs
Namespace: MyProject.Features.Auth.Services
Namespace Styles
File-Scoped Namespaces (Modern)
namespace MyProject.Services;
public class UserService
{
}
Traditional Namespaces
namespace MyProject.Services
{
public class UserService
{
}
}
The extension detects your project's style and matches it.
Manual Adjustment
If a namespace needs correction:
- Use the "Adjust Namespace" command
- The namespace will be updated based on current location
- All usings and references remain intact
Configuration
Namespace behavior respects:
- Project settings
- EditorConfig
- C# language version
- Team conventions
No manual configuration needed - it just works!