C# Painkiller
Smart file creation, code generation, project creation, namespace management and more for C#.
- VS Code 1.92.0+
- Features
- Solution Structure
- Create C# Types
- Adjust Namespaces
- Rename File By Type
- Sync Type and File Name
- Diagnostics and Analyze Solution
- Generate Mapping Methods
- Generate DTO
- Generate FluentValidation Validator
- Extract Type to File
- Sort Usings
- Extract Interface
- .NET Project Creation
- ASP.NET Templates
- MediatR and MitMediator templates
- EF Core Configuration
- Entity Framework CMD
- Go To Handler
- Color for projects
- Settings
- Issues
- Release Notes
Explore and manage your .sln / .slnx solution from the Solution Structure (beta) panel in the Explorer sidebar.
- Create/delete solution folders and projects, manage project references
- Add/remove NuGet packages — search across
nuget.configsources with pre-release toggle and version picker - Check for NuGet package updates, update one outdated package, or update all outdated packages in a project
- See installed package dependencies and known vulnerable packages when NuGet metadata is available
- Central package management for
Directory.Packages.props. Migrate all versionedPackageReferenceentries under a solution toDirectory.Packages.propsfrom the solution root folder or.sln/.slnxcontext menu
Hide with the
csharppainkiller.solutionStructure.showsetting. Disable automatic NuGet version/dependency/vulnerability checks withcsharppainkiller.solutionStructure.autoCheckPackages; manual checks remain available from the Solution Structure context menu.
Quickly scaffold new C# type files with auto-detected namespaces. Right-click a folder in the Explorer → C# Create.
Fix namespace declarations across one file or an entire folder in a single action. Right-click any .cs file or folder → C# Refactor → C# Adjust Namespaces.
Rename .cs files to match the C# type they contain. Right-click a file or folder → C# Refactor → C# Rename File By Type.
When you change the .cs file name, the name of the object in the file changes and vice versa.
Supported type kinds: class, record, struct, record struct.
Can be disabled via the
csharppainkiller.syncTypeAndFileNamesetting.
C# Painkiller reports diagnostics for open .cs files and provides C# Analyze Solution for a one-off workspace scan with selectable analyzers.
Available analyzers:
- Namespace mismatch
- File name mismatch
- Unsorted
usingdirectives - Mixed-language identifiers
- Duplicate type names within the same project
Open-files diagnostics are controlled by the csharppainkiller.diagnostics.* settings. The C# Analyze Solution command lets you choose analyzers for that run without changing your saved settings.
Generate static MapTo{TargetType} / MapFrom{TargetType} methods for mapping between types
The extension prompts for the target type, maps matching public properties, and inserts the method at the end of the source type.
Scaffold a DTO class with matching public properties and a static MapFrom{SourceType} factory method inside the DTO.
Generate a FluentValidation AbstractValidator<T> for a class, record, or struct based on its public properties. Rules are inferred from property types (strings, numbers, dates, enums, collections, and more).
Move an extra type from a multi-type file into its own {TypeName}.cs file. The quick fix appears on extractable type names when the current file contains more than one type and the selected type is not already the file's primary type.
Sort and deduplicate top-level using directives in a .cs file or across an entire folder. Right-click → C# Refactor → C# Sort Usings.
Sort order: global usings, System.* namespaces, other namespaces, static usings, then alias usings. The unsorted-usings diagnostic uses the same order.
Generate an interface from a class definition in one click. Right-click a .cs file → C# Refactor → C# Extract Interface.
Scaffold new .NET projects using dynamic templates from dotnet new list. The extension dynamically fetches available .NET templates and registers them as commands at startup, allowing you to create any project type supported by the .NET SDK.
Scaffold ASP.NET controllers and Minimal API endpoints. Right-click a folder → C# Generator → ASP.NET.
Generate requests, handlers, notifications, and pipeline behaviors. Right-click a folder → C# Generator → MediatR/MitMediator. It is not necessary to enter the full name of the request, if it is a base request like "get, create, delete, update or other" the extension will automatically substitute the name and determine whether it is a command or a query.
Scaffold Entity Framework Core entity configurations. Right-click a folder → C# Generator → EF Core, or right-click a .cs entity file directly.
Run Entity Framework Core migration commands directly from the Explorer context menu on a .csproj file:
Navigate between a MediatR/MitMediator request or notification file and its handler. Right-click a mediator .cs file in the Explorer:
- Go To Handler — open the matching handler file
- Generate Handler — create a handler if one does not exist yet
Code actions in the editor offer the same navigation when the cursor is on a request or notification type.
The names of the folders containing project files are highlighted in purple.
Use VS Code settings (Ctrl+, / Cmd+,) to control which feature groups are visible in context menus and code actions:
| Setting | Default | Description |
|---|---|---|
csharppainkiller.templates.showMediatR |
true |
Show MediatR generator commands |
csharppainkiller.templates.showMitMediator |
true |
Show MitMediator generator commands |
csharppainkiller.templates.showAspNet |
true |
Show ASP.NET generator commands |
csharppainkiller.templates.showEfCore |
true |
Show EF Core configuration commands |
csharppainkiller.templates.showFluentValidation |
true |
Show FluentValidation commands |
csharppainkiller.solutionStructure.show |
true |
Show the Solution Structure panel in the Explorer sidebar |
csharppainkiller.solutionStructure.autoCheckPackages |
true |
Automatically check NuGet package versions, dependencies, and known vulnerabilities when Solution Structure initializes |
csharppainkiller.syncTypeAndFileName |
true |
Automatically rename the .cs file when the single type inside it is renamed (on save), and rename the type when the file is renamed |
csharppainkiller.diagnostics.wrongNamespace |
true |
Warn when a file's namespace does not match its project path |
csharppainkiller.diagnostics.wrongFilename |
true |
Warn when a file name does not match its declared type name |
csharppainkiller.diagnostics.unsortedUsings |
false |
Warn when top-level using directives are not in C# Painkiller sort order |
csharppainkiller.diagnostics.mixedLanguageIdentifiers |
false |
Warn when identifiers mix Latin and non-Latin characters |
csharppainkiller.diagnosticDebounceDelay |
1000 |
Delay in milliseconds before re-analyzing an open .cs file after edits |
- If you find a bug please report it on GitHub issues
See CHANGELOG.md for the full version history.











