Skip to content

Feature: Add VB.NET support via Roslyn#627

Open
Michael2150 wants to merge 3 commits into
colbymchenry:mainfrom
Michael2150:main
Open

Feature: Add VB.NET support via Roslyn#627
Michael2150 wants to merge 3 commits into
colbymchenry:mainfrom
Michael2150:main

Conversation

@Michael2150
Copy link
Copy Markdown

@Michael2150 Michael2150 commented Jun 1, 2026

Add VB.NET support via Roslyn

Closes #170

Adds .vb file indexing to codegraph. Tree-sitter has no VB.NET grammar, and the only published option (tree-sitter-vb-dotnet) is unmaintained since July 2025, missing LINQ and XML literals, has an open licensing question, and has no published WASM build. Instead this uses Roslyn (the actual .NET compiler) via a small companion CLI tool, giving compiler-accurate extraction with full language coverage.

The integration follows the existing standalone extractor pattern used by DfmExtractor and MyBatisExtractor: a RoslynExtractor class invokes the subprocess, maps its JSON output to ExtractionResult, and plugs into the existing dispatch in extractFromSource(). No changes to the extraction pipeline architecture.

What gets extracted

Nodes: classes, modules, interfaces, structs, enums, methods, properties, fields, imports, namespaces

Edges: calls, extends, implements, overrides, instantiates, plus VB.NET-specific patterns (Handles/WithEvents event wiring, RaiseEvent)

Files changed

  • src/types.ts - 'vbnet' added to LANGUAGES
  • src/extraction/grammars.ts - .vb extension mapping; isLanguageSupported, isGrammarLoaded, getSupportedLanguages updated (without this the orchestrator silently skips every .vb file before reaching the extractor)
  • src/extraction/roslyn-extractor.ts (new) - subprocess bridge; selects the right platform binary from bin/ via process.platform + process.arch; CODEGRAPH_ROSLYN_BIN env var overrides for development
  • src/extraction/tree-sitter.ts - vbnet dispatch branch; C# continues using tree-sitter unchanged
  • package.json - "bin" added to files for binary bundling
  • __tests__/extraction.test.ts - 3 new tests; all pass without the binary present

Why not tree-sitter-vb-dotnet?

tree-sitter-vb-dotnet Roslyn
LINQ support No (marked "planned") Yes
XML literals No (marked "planned") Yes
Error recovery Basic Compiler-grade
Actively maintained No, dormant since July 2025 Yes (.NET SDK)
Licensing Open issue (7 "Unlicensed code") MIT / Apache
Published WASM No, requires manual compile n/a

Future: C# via Roslyn

C# currently continues to use the tree-sitter extractor unchanged. The RoslynExtractor already detects .cs files and the companion tool supports C# extraction with the same node/edge coverage. Switching C# over in a follow-up PR would give it the same compiler-accurate extraction, with better qualified name resolution and semantic edges that tree-sitter can't provide.

Companion tool

Michael2150/codegraph-roslyn is a .NET 8 console app using Microsoft.CodeAnalysis.VisualBasic. It has 131 xUnit tests covering nodes, edges, and VB.NET-specific patterns and cross-compiles to all five platform targets from a single runner.

Binaries

The platform executables are not committed to this repo. They should be downloaded from the codegraph-roslyn v1.0.0 release and placed in bin/ before publishing:

File Platform
codegraph-roslyn-win-x64.exe Windows x64
codegraph-roslyn-osx-x64 macOS Intel
codegraph-roslyn-osx-arm64 macOS Apple Silicon
codegraph-roslyn-linux-x64 Linux x64
codegraph-roslyn-linux-arm64 Linux ARM64

Happy to add a download step to the release workflow if that's the preferred approach.

Michael2150 and others added 2 commits June 1, 2026 19:17
Introduce VB.NET support by adding a Roslyn-based extractor (src/extraction/roslyn-extractor.ts) that invokes a bundled or env-provided codegraph-roslyn binary. Wire vbnet into language lists and detection: add '.vb' extension mapping, include vbnet in LANGUAGES and getSupportedLanguages(), and mark it as supported/no-WASM grammar in grammars.ts. Hook the RoslynExtractor into extractFromSource so VB.NET files are extracted via Roslyn. Add unit tests for VB.NET detection and update package.json to include the bundled bin artifacts. Update CHANGELOG to announce VB.NET support.
@Michael2150 Michael2150 changed the title Add VB.NET support via Roslyn Feat/Add VB.NET support via Roslyn Jun 1, 2026
@Michael2150 Michael2150 changed the title Feat/Add VB.NET support via Roslyn Feature: Add VB.NET support via Roslyn Jun 1, 2026
Store the provided source as a class property and pass it to the Roslyn extractor binary via stdin. The execFileSync call now includes a --stdin flag and the input option is set to this.source, so the binary doesn't need to locate the file on disk (the existing --file arg is retained for node IDs / qualified name generation). A brief comment explaining the change was also added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Visual Basic support would be incredible =)

2 participants