C# for Visual Studio Code (powered by OmniSharp)
- MITRE ATT&CK for Visual Studio Code. Provides features for working with MITRE ATT&CK techniques. Editor Features Code Completion. This extension provides Intellisense-like support for ATT&CK tactics, techniques and sub-techniques. This includes completions for technique names too, so typing either Powers or T1059.001 will insert the appropriate.
- Visual Studio extension development. Create add-ons and extensions for Visual Studio, including new commands, code analyzers, and tool windows. Add the SDKs and tools you need to create new commands, code analyzers, tool windows, and language services using C#. Then, share your extension with the community in the Visual Studio.
- Visual Studio IDE Visual Studio for Mac Visual Studio Code To continue downloading, click here Download Older Visual Studio Software Visual Studio 2021-03-29T08:30:31-07:00.
Welcome to the C# extension for Visual Studio Code! This extension provides the following features inside VS Code:
- Lightweight development tools for .NET Core.
- Great C# editing support, including Syntax Highlighting, IntelliSense, Go to Definition, Find All References, etc.
- Debugging support for .NET Core (CoreCLR). NOTE: Mono debugging is not supported. Desktop CLR debugging has limited support.
- Support for project.json and csproj projects on Windows, macOS and Linux.
The C# extension is powered by OmniSharp.
Get Started Writing C# in VS Code
Note about using .NET Core 3.1.40x SDKs
The .NET 3.1.40x SDKs require version 16.7 of MSBuild.
For MacOS and Linux users who have Mono installed, this means you will need to set
never until a version of Mono ships with MSBuild 16.7.
Note about using .NET 5 SDKs
The .NET 5 SDK requires version 16.8 of MSBuild.
For Windows users who have Visual Studio installed, this means you will need to be on the latest Visual Studio 16.8 Preview.For MacOS and Linux users who have Mono installed, this means you will need to set
never until a version of Mono ships with MSBuild 16.8.
What's new in 1.23.11
- Move the global Mono check to the correct place (#4489, PR: #4492)
What's new in 1.23.10
- Support solution filters (*.slnf) (PR: #4481)
- Prompt user to install Blazor WASM companion extension if needed (PR: #4392)
- Add path to dotnet so child processes can use the CLI (PR: #4459)
- Give more information when Mono is missing or invalid. (#4428, PR: #4431)
- Revert incremental change forwarding (PR: #4477)
- Fixes to asset generation (PR: #4402)
- Add properties to blazorwasm debug configuration. (dotnet/aspnetcore#30977, PR: i#4445)
- Avoid white status bar items to ensure contrast (#4384, PR: #4385)
- Update OmniSharp to 1.37.8
- Update Roslyn version to
- Update included build tools to closely match NET 6 Preview 1 SDK (PR: omnisharp-roslyn#2103)
- Improve custom error messages for MSB3644 (PR: omnisharp-roslyn#2097)
- Do not call FindReferencesAsync for null symbol (omnisharp-roslyn#2054, PR: omnisharp-roslyn#2089)
- use an OmniSharp specific message for MSB3644 (omnisharp-roslyn#2029, PR: omnisharp-roslyn#2069)
- changed the default RunFixAllRequest timeout to 10 seconds (PR: omnisharp-roslyn#2066)
- Support Solution filter (.slnf) (PR: omnisharp-roslyn#2121)
- updated to IL Spy 18.104.22.16872 (PR: omnisharp-roslyn#2113)
- Add sentinel file to MSBuild to enable workload resolver (#4417, PR: omnisharp-roslyn#2111)
- fixed CS8605 'Unboxing possibly null value' (PR: omnisharp-roslyn#2108)
- Update Roslyn version to
- Updated Razor support (PR: #4470)
- Bug fixes
What's new in 1.23.9
- Add option to organize imports during document formatting. (PR: #4302)
- Update to use zero based indexes (PR: #4300)
- Improve request queues to improve code completion performance (PR: #4310)
- Add setting to control whether to show the OmniSharp log on error (#4102, #4330, PR: #4333)
- Support building launch assets for NET6-NET9 projects (#4346, PR: #4349)
- Add debugger support for Concord extensions. See the ConcordExtensibilitySamples wiki for more information.
- Update OmniSharp version to 1.37.6
- Handle records in syntax highlighting (#2048, PR: #2049)
- Remove formatting on new line (PR: #2053)
- Validate highlighting ranges in semantic highlighting requests (PR: #2055)
- Delay project system init to avoid solution update race (PR: #2057)
- Use 'variable' kind for parameter completion (#2060, PR: #2061)
- Log request when response fails (#2064)
What's new in 1.23.8
- Updated Debugger support (PR: #4281)
- Updated the version of .NET that the debugger uses for running its own C# code to .NET 5
- Updated .NET debugging services loader to address problem with debugging after installing XCode12 (dotnet/runtime/#42311)
- Fixed integrated terminal on non-Windows (#4203)
- Updated Razor support (PR: #4278)
- Bug fixes
- Update OmniSharp version to 1.37.5 (PR: #4299)
- Update Roslyn version to 3.9.0-2.20570.24 (PR: omnisharp-roslyn#2022)
- Editorconfig improvements - do not lose state, trigger re-analysis on change (omnisharp-roslyn#1955, #4165, #4184, PR: omnisharp-roslyn#2028)
- Add documentation comment creation to the FormatAfterKeystrokeService (PR: omnisharp-roslyn#2023)
- Raise default GotoDefinitionRequest timeout from 2s to 10s (#4260, PR: omnisharp-roslyn#2032)
- Workspace create file workaround (PR: omnisharp-roslyn#2019)
msbuild:UseBundledOnlyoption to force the usage of bundled MSBuild (PR: omnisharp-roslyn#2038)
- Support auto doc comment generation (#8, PR: #4261)
- Add schema support for appsettings.json (#4279, PR: #4280)
- Add schema support for global.json (PR: #4290)
- Update remoteProcessPickerScript windows ssh exit (#3482, PR: #4225)
- Do not start OmniSharp server in Live Share scenarios (#3910, PR: #4038)
- Suppress codelens for IEnumerable.GetEnumerator (#4245, PR: #4246)
- Allow arm64 MacOS to debug dotnet projects (#4277, PR: #4288)
Emmet support in Razor files
To enable emmet support, add the following to your settings.json:
The C# semantic highlighting support is in preview. To enable, set
true in your settings. Semantic highlighting is only provided for code files that are part of the active project.
To really see the difference, try the new Visual Studio 2019 Light and Dark themes with semantic colors that closely match Visual Studio 2019.
Supported Operating Systems for Debugging
Currently, the C# debugger officially supports the following operating systems:
- X64 operating systems:
- Windows 7 SP1 and newer
- macOS 10.12 (Sierra) and newer
- Linux: see .NET Core documentation for the list of supported distributions. Note that other Linux distributions will likely work as well as long as they include glibc and OpenSSL.
- ARM operating systems:
- Linux is supported as a remote debugging target
- X64 operating systems:
Found a Bug?
To file a new issue to include all the related config information directly from vscode by entering the command pallette with Ctrl+Shift+P(Cmd+Shift+P on macOS) and running
CSharp: Report an issue command. This will open a browser window with all the necessary information related to the installed extensions, dotnet version, mono version, etc. Enter all the remaining information and hit submit. More information can be found on the wiki.
Alternatively you could visit https://github.com/OmniSharp/omnisharp-vscode/issues and file a new one.
- Node.js (8.11.1 or later)
- Npm (5.6.0 or later)
To run and develop do the following:
npm run compile
- Open in Visual Studio Code (
- Optional: run
npm run watch, make code changes
- Press F5 to debug
To test do the following:
npm run test or F5 in VS Code with the 'Launch Tests' debug configuration.
Copyright © .NET Foundation, and contributors.
The Microsoft C# extension is subject to these license terms.The source code to this extension is available on https://github.com/OmniSharp/omnisharp-vscode and licensed under the MIT license.
Code of Conduct
This project has adopted the code of conduct defined by the Contributor Covenantto clarify expected behavior in our community.For more information see the .NET Foundation Code of Conduct.
Contribution License Agreement
By signing the CLA, the community is free to use your contribution to .NET Foundation projects.
This project is supported by the .NET Foundation.
IntelliSense shows you intelligent code completion, hover info, and signature information so that you can write code more quickly and correctly.
express; and for other platforms such as
node, serverless, or IoT.
jsconfig.json files are not required, you will want to create one in cases such as:
jsconfig.jsonfiles let you exclude some files from showing up in IntelliSense.
jsconfig.jsonat the root folder of each project.
jsconfig.json at the root of your workspace:
There are many extensions that provide additional snippets, including snippets for popular frameworks such as Redux or Angular. You can even define your own snippets.
Tip: To disable snippets suggestions, set
'none' in your settings file. The
editor.snippetSuggestions setting also lets you change where snippets appear in the suggestions: at the top (
'top'), at the bottom (
'bottom'), or inlined ordered alphabetically (
'inline'). The default is
Quickly create JSDoc comments for functions by typing
/** before the function declaration, and select the JSDoc comment snippet suggestion:
To disable JSDoc comment suggestions, set
The ⌘K ⌘I (Windows, Linux Ctrl+K Ctrl+I) keyboard shortcut shows this hover info at the current cursor position.
Signature help is shown automatically when you type a
, within a function call. Press ⇧⌘Space (Windows, Linux Ctrl+Shift+Space) to manually trigger signature help.
Automatic imports speed up coding by suggesting available variables throughout your project and its dependencies. When you select one of these suggestions, VS Code automatically adds an import for it to the top of the file.
If you choose one of these auto import suggestions, VS Code adds an import for it.
In this example, VS Code adds an import for
Button from material-ui to the top of the file:
Visual Studio Code Visual Basic
To disable auto imports, set
Tip: VS Code tries to infer the best import style to use. You can explicitly configure the preferred quote style and path style for imports added to your code with the
false to disable it.
JSX and auto closing tags
You can use JSX syntax in both normal
*.js files and in
VS Code also includes JSX-specific features such as autoclosing of JSX tags:
false to disable JSX tag closing.
- Go To DefinitionF12 - Go to the source code of a symbol definition.
- Peek Definition⌥F12 (Windows Alt+F12, Linux Ctrl+Shift+F10) - Bring up a Peek window that shows the definition of a symbol.
- Go to References⇧F12 (Windows, Linux Shift+F12) - Show all references to a symbol.
- Go to Type Definition - Go to the type that defines a symbol. For an instance of a class, this will reveal the class itself instead of where the instance is defined.
You can navigate via symbol search using the Go to Symbol commands from the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)).
- Go to Symbol in File⇧⌘O (Windows, Linux Ctrl+Shift+O)
- Go to Symbol in Workspace⌘T (Windows, Linux Ctrl+T)
Available refactorings include:
- Extract to method or function.
- Extract to constant.
- Convert between named imports and namespace imports.
- Move to new file.
See Refactorings for more information about refactorings and how you can configure keyboard shortcuts for individual refactorings.
Unused variables and unreachable code
if statement that is always true or an unreferenced import, is faded out in the editor:
You can quickly remove this unused code by placing the cursor on it and triggering the Quick Fix command (⌘. (Windows, Linux Ctrl+.)) or clicking on the lightbulb.
To disable fading out of unused code, set
You can run Organize Imports from the Source Action context menu or with the ⇧⌥O (Windows, Linux Shift+Alt+O) keyboard shortcut.
Code Actions on Save
editor.codeActionsOnSave setting lets you configure a set of Code Actions that are run when a file is saved. For example, you can enable organize imports on save by setting:
You can also set
editor.codeActionsOnSave to an array of Code Actions to execute in order.
Here are some source actions:
'organizeImports'- Enables organize imports on save.
'fixAll'- Auto Fix on Save computes all possible fixes in one round (for all providers including ESLint).
'fixAll.eslint'- Auto Fix only for ESLint.
'addMissingImports'- Adds all missing imports on save.
VS Code automatically suggests some common code simplifications such as converting a chain of
.then calls on a promise to use
false to disable suggestions.
To enable the references CodeLens, set
Click on the reference count to quickly browse a list of references:
Update imports on file move
'prompt'- The default. Asks if paths should be updated for each file move.
'always'- Always automatically update paths.
'never'- Do not update paths automatically and do not prompt.
Tip: This list is dynamically queried from the VS Code Marketplace. Read the description and reviews to decide if the extension is right for you.
TypeScript tried to infer types in
.js files the same way it does in
Debug client side
You can debug your client-side code using a browser debugger such as Debugger for Chrome, Debugger for Edge or Debugger for Firefox.
Debug server side
Debug Node.js in VS Code using the built-in debugger. Setup is easy and there is a Node.js debugging tutorial to help you.
Tip: The extensions shown above are dynamically queried. Click on an extension tile above to read the description and reviews to decide which extension is best for you. See more in the Marketplace.
Read on to find out about:
- jsconfig.json - Detailed description of the
- IntelliSense - Learn more about IntelliSense and how to use it effectively for your language.
- Debugging - Learn how to set up debugging for your application.
- Node.js - A walkthrough to create an Express Node.js application.
Watch these introductory videos:
- Debugging - Learn how to debug a Node.js application.
Visual Studio Code Visual Debugger
Does VS Code support JSX and React Native?
VS Code supports JSX and React Native. You will get IntelliSense for React/JSX and React Native from automatically downloaded type declaration (typings) files from the npmjs type declaration file repository. Additionally, you can install the popular React Native extension from the Marketplace.
To enable ES6 import statements for React Native, you need to set the
allowSyntheticDefaultImports compiler option to
true. This tells the compiler to create synthetic default members and you get IntelliSense. React Native uses Babel behind the scenes to create the proper run-time code with default members. If you also want to do debugging of React Native code, you can install the React Native Extension.
Does VS Code support the Dart programming language and the Flutter framework?
Yes, there are VS Code extensions for both Dart and Flutter development. You can learn more at the Flutter.dev documentation.
IntelliSense is not working for external libraries
Automatic Type Acquisition works for dependencies downloaded by npm (specified in
package.json), Bower (specified in
bower.json), and for many of the most common libraries listed in your folder structure (for example
ES6 Style imports are not working.
When you want to use ES6 style imports but some type declaration (typings) files do not yet use ES6 style exports, then set the TypeScript compiler option
allowSyntheticDefaultImports to true.
How do I disable Syntax Validation when using non-ES6 constructs?
Some users want to use syntax constructs like the proposed pipeline (