A powerful Visual Studio Code extension that allows you to quickly generate C# files with predefined templates, ensuring consistent structure and reducing repetitive work.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
A powerful Visual Studio Code extension that allows you to quickly generate C# files with predefined templates, ensuring consistent structure and reducing repetitive work.
✨ Features
Automatically generates C# Classes, Interfaces, Controllers, DTOs, Enums, Services, Razor Views, and more.
Ensures consistent file naming and namespace generation.
Prevents duplicate files and handles missing extensions.
Provides a Quick Pick menu to select the file type when creating a new file.
Supports custom templates via settings.json.
📌 Installation
Open VS Code.
Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X on macOS).
Search for C# File Generator.
Click Install.
🚀 Usage
Create a new file in your project (e.g., UserService).
If no extension is provided, the extension prompts you to select one (.cs, .cshtml, .json, etc.).
Choose the file type (Class, Interface, Controller, etc.).
The extension generates the correct file structure and opens the file in the editor.
⚙️ Configuration (Custom Templates)
You can customize templates by modifying your VS Code settings:
Open Settings (Ctrl+, / Cmd+, on macOS).
Search for csharpTemplates.
Modify or add custom file templates in settings.json:
"csharpTemplates.templates": {
"CustomType": "using System;\n\nnamespace {{NAMESPACE}}\n{\n public class {{NAME}} { }\n}"
}
📂 File Naming Rules
Classes → UserService.cs
Interfaces → IUserService.cs
Controllers → UserController.cs
DTOs → UserDto.cs
Services → UserService.cs
Enums → UserType.cs
Razor Views → Index.cshtml
❗ Known Issues
If a file is mistakenly created without an extension, the extension will automatically delete it and create the correct version.
🛠️ Contributing
Fork this repository.
Create a new branch (feature/new-feature).
Commit your changes.
Push to the branch and create a Pull Request.
📄 License
This extension is open-source and licensed under the MIT License.