Visual Basic for VS Code (Roslyn)
Visual Basic support for VS Code on Windows and Linux, built directly on the Roslyn compiler platform: the same engine
that compiles your code analyses it in the editor.
Status: preview. It is developed and tested against .NET 10. It is not on the Marketplace yet; build the package
yourself (see Building).
What it does
Editing (Roslyn's own services, so the answers match the compiler's)
- Errors and warnings as you type (compiler and analyzers,
.editorconfig severities honoured): for open files, or for the whole project with vb.diagnostics.scope
- Completion (with automatic
Imports), hover, signature help
- Go to definition, type definition and implementation; find references; rename; document highlights
- Quick fixes and refactorings from Roslyn's own providers
- Formatting (document, selection, as you type), folding, selection ranges, semantic highlighting, inlay hints, code lens
- Document and workspace symbols, call hierarchy and type hierarchy
- Projects, solutions (
.sln, .slnx) and files outside any project; a VB project that references C# sees through it
Running and debugging
- Debugging (Windows and Linux) with Visual Basic expressions in watches, hovers and the Debug Console, breakpoint
conditions and log points; Async and Iterator methods show their locals under the names in your code;
My.* works
- Launch, or attach to a running .NET program (
Attach to a Visual Basic program, with a process picker)
- F5 builds the project first, so you debug the code on screen
- Edit and Continue: edit and save while stopped or running, and the change is applied to the running program
- Hot reload without a debugger: Run with Hot Reload (Ctrl+F5 in a Visual Basic file)
Projects and tests
- Commands to add and remove NuGet packages and project references, restore, build and clean
- New Project and New File: projects come from
dotnet new (so any installed Visual Basic template shows up); files include Class, Module, Interface, Structure and Enum
- Delete bin and obj Folders: right-click a project, a Visual Basic file or a folder (a folder cleans every project under it)
- F5 on a
.vbproj or a Visual Basic file debugs the project it belongs to, with no launch.json to create
- Test Explorer integration for
dotnet test
- Snippets
Requirements
- VS Code 1.85 or later
- The .NET SDK (10.0 or later): the extension runs its language server and debug adapter with your installed .NET
- Windows x64, Linux x64 or Linux arm64. One package serves all of them; the debugger for your platform is picked automatically
In a Remote - WSL or Dev Containers window the extension runs on the remote side, which then needs the .NET SDK (this is how it is meant to work; it has not been tried in those windows yet).
Settings
| Setting |
Purpose |
vb.diagnostics.scope |
Which files get errors reported: openFiles (default) or project |
vb.server.dotnetPath |
The dotnet to run the server and the debug adapter with |
vb.server.path, vb.debugAdapter.path, vb.debugger.path |
Use your own build of the server, adapter or debugger |
Debugging notes
- Edit and Continue works when the debugger starts the program. It is not available when you attach to a running process.
- A running program on Windows holds its
.dll open, so F5 cannot rebuild it: stop it first.
- The debugger's expression evaluator has limits that no translation can fix (casts,
TypeOf ... Is, New, lambdas...).
These answer "not supported by the debugger's expression evaluator".
- A paused frame in a method you then edit stays on the old code until it returns; later calls run the new code.
Building
cd vscode-extension
npm install
npm run compile
node scripts/stage.js --netcoredbg win-x64=<folder> --netcoredbg linux-x64=<folder>
npx @vscode/vsce package
The debugger is netcoredbg at a pinned commit with a small patch for Edit and
Continue: build it with tools/netcoredbg/build.sh on each platform (CI does this and assembles one package). node scripts/check-package.js checks that a package has everything it needs. The design and the open work are in
docs/PLAN.md in the repository.
License
MIT. The bundled debugger is netcoredbg (MIT, Samsung Electronics); its licence ships next to it.
| |