Published on Sun May 10 2020 00:00:00 GMT+0000 (Coordinated Universal Time) by Dominic Böttger
Visual Studio Code is my favorite Code Editor and I like that it’s so lightweight and also wanted to use it for C# development instead of the full-blown Visual Studio experience.
Some time ago I tried to use Visual Studio Code instead but I was missing some things to improve the development workflow. I wanted to have features like live unit testing and better guidance while coding C#. I tested some plugins and some configurations and now I think I found a solution to fulfill my needs.
Essential Extensions
- C# - THE C# extension powered by OmniSharp
- .NET Core Test Explorer - Live testing while coding
- Auto-using - Automatically adds using statements
- C# FixFormat - Auto-format code on save
- Coverage Gutters - Visualize code coverage
- Fakesharper - Integrates Resharper into VSCode
Configuration
Add these settings to .vscode/settings.json:
{
"dotnet-test-explorer.testProjectPath": "**/*Test.csproj",
"dotnet-test-explorer.autoWatch": true,
"dotnet-test-explorer.testArguments": "/p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./lcov.info",
"omnisharp.enableRoslynAnalyzers": true,
"csharpfixformat.sort.usings.enabled": true,
"editor.formatOnSave": true,
"[csharp]": {
"editor.defaultFormatter": "Leopotam.csharpfixformat"
}
}
StyleCop Integration
Add StyleCop.Analyzers via NuGet, then add the ruleset path to your csproj:
<PropertyGroup>
<CodeAnalysisRuleSet>..\StyleCop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
A complete example template is available at github.com/dominicboettger
Written by Dominic Böttger
← Back to blog