5.2 KiB
5.2 KiB
RESX Designer Auto-Generator
A VS Code extension that automatically regenerates Designer.cs files when RESX resource files are saved.
Features
- Automatic Regeneration: Watches for changes to .resx files and automatically regenerates corresponding Designer.cs files
- Smart Detection: Automatically finds ResGen.exe on your system across different .NET SDK and Visual Studio installations
- Debounced Updates: Prevents excessive regeneration during rapid file changes
- Status Updates: Shows progress in the status bar with visual indicators
- Configurable: Customizable settings for different project needs
- Cross-Platform: Works on Windows, macOS, and Linux (where .NET SDK is available)
Requirements
- .NET SDK or Visual Studio installed (for ResGen.exe)
- VS Code 1.101.0 or higher
Quick Start
- Install the extension
- Open a workspace containing .resx files
- Edit and save a .resx file
- Watch as the Designer.cs file is automatically regenerated!
Configuration
The extension can be configured through VS Code settings:
resxDesignerAutoGenerator.enabled
- Type:
boolean - Default:
true - Description: Enable/disable automatic regeneration
resxDesignerAutoGenerator.showNotifications
- Type:
boolean - Default:
true - Description: Show success/error notifications
resxDesignerAutoGenerator.debounceDelay
- Type:
number - Default:
2000 - Range: 500-10000
- Description: Delay in milliseconds before regenerating after a file change
resxDesignerAutoGenerator.resGenPaths
- Type:
array - Default:
[] - Description: Custom paths to ResGen.exe (auto-detected if empty)
resxDesignerAutoGenerator.watchPatterns
- Type:
array - Default:
["**/*.resx"] - Description: Glob patterns for watching .resx files
Commands
RESX Designer: Regenerate Designer.cs
Manually regenerate the Designer.cs file for a selected .resx file. Available in:
- Command Palette (Ctrl+Shift+P)
- Explorer context menu (right-click on .resx files)
RESX Designer: Show Output
Show the extension's output channel for debugging and monitoring.
RESX Designer: Reload Configuration
Reload the extension configuration and restart file watchers.
How It Works
- File Watching: The extension monitors .resx files in your workspace using VS Code's FileSystemWatcher API
- Debouncing: When a .resx file changes, the extension waits for the configured delay to avoid rapid-fire regenerations
- ResGen Detection: Automatically finds ResGen.exe in common locations:
- .NET Framework SDK locations
- Visual Studio installations (2019, 2022)
- System PATH
- Namespace Detection: Analyzes your project structure to determine the correct namespace for generated classes
- Code Generation: Executes ResGen.exe with the appropriate parameters to generate strongly-typed Designer.cs files
- Cleanup: Removes temporary .resources files that ResGen creates
Supported File Patterns
By default, the extension watches for files matching:
**/*.resx- All .resx files in the workspace
You can customize this in the settings to watch specific folders or file patterns.
Troubleshooting
ResGen.exe Not Found
If you see this error, try:
- Install the .NET SDK from https://dotnet.microsoft.com/download
- Install Visual Studio with .NET development workload
- Manually specify the path in
resxDesignerAutoGenerator.resGenPathssetting
Designer.cs Not Generated
- Check the Output panel (View → Output → RESX Designer Auto-Generator)
- Ensure the .resx file is valid XML
- Verify write permissions in the project directory
- Try the manual regenerate command
Performance Issues
- Adjust the
debounceDelaysetting to a higher value - Use more specific
watchPatternsto exclude unnecessary files - Add large folders to VS Code's
files.watcherExcludesetting
Example Configuration
{
"resxDesignerAutoGenerator.enabled": true,
"resxDesignerAutoGenerator.showNotifications": false,
"resxDesignerAutoGenerator.debounceDelay": 3000,
"resxDesignerAutoGenerator.watchPatterns": [
"**/Resources/**/*.resx",
"**/Properties/**/*.resx"
]
}
Installation
From VS Code Marketplace
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search for "RESX Designer Auto-Generator"
- Click Install
From VSIX File
- Download the .vsix file
- Open VS Code
- Press Ctrl+Shift+P
- Type "Extensions: Install from VSIX"
- Select the downloaded .vsix file
Development
To contribute or modify this extension:
git clone <repository-url>
cd resx-designer-auto-generator
npm install
code .
Press F5 to launch a new VS Code window with the extension loaded for testing.
License
This extension is released under the MIT License. See LICENSE file for details.
Support
- Report issues on GitHub Issues
- Feature requests welcome!
Changelog
1.0.0
- Initial release
- Automatic .resx file watching
- Designer.cs regeneration
- Configurable settings
- Status bar integration
- Command palette integration