.NET Extension Pack for VS Code (CSharpDev)
This extension pack for Visual Studio Code aims to enhance the .NET development experience by providing a comprehensive set of tools and features to manage projects, code, NuGet packages, tests, tasks, and much more.
Key Features
1. .NET Project and Solution Management
- Create Projects: Create new .NET projects from selected templates and automatically add them to an existing solution.
- Manage Project References: Add or remove references between C# projects within your solution.
- Create Solutions: Generate new .NET solution files (
.sln or the new .slnx format).
- Add Projects to Solution: Incorporate existing
.csproj projects into a solution.
- Remove Projects from Solution: Unlink projects from a solution file.
2. Code Generation and Snippets
- Intelligent Snippets: Use snippets to quickly generate C# code structures like classes, interfaces, enums, records, and endpoints.
- Snippets automatically include the namespace and class name calculated based on the file location and the nearest
.csproj .
- Convert JSON to C# Classes: Paste JSON from the clipboard and automatically convert it into C# classes in the active editor or a new file.
- Convert XML to C# Classes: Paste XML from the clipboard and transform it into C# class definitions.
- Generate GUID: Create and insert GUIDs (UUIDs) into the editor with various formatting options (uppercase/lowercase, with/without hyphens, with/without braces).
3. NuGet Package Management
- Install Packages: Search and install NuGet packages into your projects, with options to select the version and include pre-releases.
- Uninstall Packages: Remove NuGet packages from a project.
- Update Packages: Check and update NuGet packages to their latest versions (stable or pre-releases, as configured).
- Check for Vulnerabilities: Run a scan for known vulnerabilities in your project's NuGet packages.
4. .NET Test Integration (Test Explorer)
- Automatic Discovery: Automatically detects test projects (
.csproj ) in the workspace.
- Test Explorer View: Displays tests hierarchically (Project -> Namespace -> Class -> Method).
- Run Tests: Run tests individually, by class, namespace, or project.
- Debug Tests: Start debugging sessions for your tests directly from the Test Explorer.
- The system detects the test host process ID and attaches the debugger.
- Code Coverage: Run tests with code coverage data collection (requires
coverlet.collector ).
- Analyzes coverage reports in OpenCover and Cobertura formats.
- Displays coverage directly in the code files.
- Detailed Results: Processes
.trx result files to provide feedback on the status of each test.
5. Code Notes (TODOs, FIXMEs)
- Notes Viewer: Find and view code annotations like
TODO: , FIXME: , BUG: in your C# files.
- Easy Navigation: Notes are displayed in a TreeView, organized by Workspace Folder -> Folder -> File -> Note.
- Go to Code: Click on a note to navigate directly to the corresponding line in the file.
- Configurable Terms: Customize the search terms for notes (e.g.,
HACK: , NOTE: ).
6. Asset and Build Task Management
- Debug Files and Tasks: Automatically generate and update
launch.json (debug configurations) and tasks.json (build, clean, publish tasks, etc.) for executable projects and solutions.
- Includes generation of Dockerfiles and
.dockerignore for executable projects.
- Monitors
launchSettings.json for automatic updates.
- Common .NET Assets: Create common files from the .NET ecosystem like
.editorconfig , .gitignore , global.json , and nuget.config .
- Common MSBuild Files: Generate
Directory.Build.props , Directory.Build.targets , and Directory.Packages.props .
- Task Viewer: A dedicated TreeView displays tasks defined in
.vscode/tasks.json , allowing for their direct execution.
- Global Tools (.NET Global Tools):
- Install, uninstall, and update .NET global tools.
- .NET Workloads:
- Install, uninstall, update, and repair .NET SDK workloads.
8. Miscellaneous Utilities
- Status Bar Clock and Timer:
- Displays the current time.
- Allows starting a countdown timer, with a visual and audible alert (if configured in the system) upon expiration.
- Development Certificates:
- Command to trust the .NET HTTPS development certificate (
dotnet dev-certs https --trust ).
- Shortcut Commands:
- Registers commands for quick access to VS Code functionalities like "Save All Files," "Reload Window," "Start Debugger," etc. (Some may be default settings or aliases).
9. AI-Powered Commit Messages
- Automatic Generation: Use AI (Google Gemini) to generate commit messages based on your changes (
git diff ).
- Conventional Commits: Messages are formatted following the Conventional Commits standard.
- SCM Integration: Automatically populates the Git commit message box in VS Code.
- Requires Configuration: Needs a Google AI API key.
10. Database Management (Entity Framework Core)
- Create Migrations: Generate new EF Core migrations for a selected project and DbContext.
- Remove Migrations: Remove the last applied migration.
- Update Database: Apply pending migrations to the database.
- Generate SQL Script: Create an SQL script from migrations, with an option for an idempotent script.
How to Use
Most features can be accessed via the Command Palette (Ctrl+Shift+P or Cmd+Shift+P). Look for commands prefixed with "CSharpDev", ".NET", "EF", "NuGet", "AI", etc.
Some features have dedicated viewers in the VS Code sidebar:
- Code Notes
- Workspace Tasks
- Test Explorer (integrated with VS Code's native Test Explorer)
Configuration
Some features may require specific configuration in VS Code settings (settings.json ):
csharpdev.notes.searchTerms : List of terms to search for in code notes (e.g., ["TODO:", "FIXME:"] ).
csharpdev.googleAi.apiKey : Your Google AI API key for commit message generation.
csharpdev.googleAi.model : Google AI model to be used (e.g., gemini-1.5-flash-latest ).
csharpdev.googleAi.language : Language for generated commit messages (e.g., en-US ).
csharpdev.nuget.usePrerelease : If true , includes pre-release versions in NuGet package search and updates.
csharpdev.nuget.overwritePackage : If true , allows reinstalling a NuGet package even if the selected version is already current.
csharpdev.tool.usePrerelease : If true , includes pre-releases when searching for .NET global tools.
csharpdev.workload.usePrerelease : If true , includes pre-releases when installing .NET workloads.
csharpdev.database.idempotentScripts : If true , generates EF Core migration SQL scripts idempotently.
csharpdev.testExplorer.debugJustMyCode : If true (default false ), enables "Just My Code" when debugging tests.
Refer to the extension's "Contributions" tab in VS Code for a complete list of available commands and settings.
| |