File Templates & Quick File Creation
Quick Add New File (Shift+F2)
The fastest way to create files in your .NET projects.
Overview
Section titled “Overview”Quick Add New File is activated with Shift+F2 and provides instant file creation with intelligent defaults.
Basic Usage
Section titled “Basic Usage”Single File Creation
Section titled “Single File Creation”- Select a folder or project in Solution Explorer
- Press
Shift+F2 - Enter a filename:
MyClass.cs - Press Enter
The file is created with:
- Appropriate template based on filename
- Correct namespace
- Standard formatting
- Ready to edit
File Type Detection
Section titled “File Type Detection”The extension detects file types automatically:
IMyService.cs→ Interface templateMyEnum.cs→ Enum templatePersonRecord.cs→ Record templateMyController.cs→ Controller template (in web projects)MyTest.cs→ Test class (in test projects)
Creating Multiple Files
Section titled “Creating Multiple Files”Comma-Separated List
Section titled “Comma-Separated List”Create several files at once:
UserService.cs, IUserService.cs, UserDto.csAll three files are created in the selected location.
With Folders
Section titled “With Folders”Include folder paths:
Services/UserService.cs, Models/User.cs, Tests/UserTests.csFolders are created automatically if they don’t exist.
Creating Folders
Section titled “Creating Folders”Empty Folders
Section titled “Empty Folders”Create a folder by adding a trailing slash:
NewFolder/Folders with Files
Section titled “Folders with Files”Combine folder and file creation:
Utils/, Utils/StringHelper.csAdvanced Syntax
Section titled “Advanced Syntax”Nested Structures
Section titled “Nested Structures”Create complex folder hierarchies:
Features/Users/Services/UserService.csAll intermediate folders are created automatically.
Multiple Files in New Folder
Section titled “Multiple Files in New Folder”Authentication/AuthService.cs, Authentication/IAuthService.csBoth files are created inside the new Authentication folder.
Common Patterns
Section titled “Common Patterns”Service Layer
Section titled “Service Layer”Services/IUserService.cs, Services/UserService.cs, Services/Dto/UserDto.csFeature Folder
Section titled “Feature Folder”Features/Orders/OrdersController.cs, Features/Orders/OrderService.cs, Features/Orders/OrderViewModel.csTest Setup
Section titled “Test Setup”Tests/Unit/UserServiceTests.cs, Tests/Integration/UserIntegrationTests.csTips and Tricks
Section titled “Tips and Tricks”Quick Interface Creation
Section titled “Quick Interface Creation”For an interface and implementation:
IMyService.cs, MyService.csBatch File Creation
Section titled “Batch File Creation”Create related files together:
User.cs, UserDto.cs, UserValidator.cs, UserProfile.csOrganizing by Feature
Section titled “Organizing by Feature”Features/Users/Commands/, Features/Users/Queries/, Features/Users/Models/Integration
Section titled “Integration”Automatic Namespace
Section titled “Automatic Namespace”All created files get the correct namespace based on:
- Project root namespace
- Folder location within project
- .NET conventions
Solution Explorer Updates
Section titled “Solution Explorer Updates”- Files appear immediately in the tree
- No manual refresh needed
- Can edit files right away
IntelliSense Integration
Section titled “IntelliSense Integration”- New files are recognized instantly
- Types are available for IntelliSense
- No project reload required
Troubleshooting
Section titled “Troubleshooting”File Not Created
Section titled “File Not Created”If a file isn’t created:
- Check filename is valid (no special characters)
- Verify you have write permissions
- Ensure parent folder exists or will be created
- Check Output panel for errors
Wrong Template Applied
Section titled “Wrong Template Applied”If the wrong template is used:
- Use explicit naming (e.g.,
IMyInterface.csfor interfaces) - Manually edit the generated file
- Future files will use pattern matching
Namespace Incorrect
Section titled “Namespace Incorrect”If namespace is wrong:
- Check project settings
- Verify folder structure
- Use the namespace adjustment feature to fix