Roslyn-based extractor for @colbymchenry/codegraph. Parses VB.NET and C# source files using the actual .NET compiler API and emits a JSON symbol graph — classes, modules, methods, properties, fields, enums, imports, call edges, inheritance edges — for import into codegraph's SQLite index.
Tree-sitter has no VB.NET grammar and its C# grammar lacks semantic information. This tool fills that gap by running as a subprocess invoked by the RoslynExtractor bridge in codegraph.
Check the PR first: VB.NET support is tracked in colbymchenry/codegraph#627. If that PR has been merged, the functionality is available in the official
@colbymchenry/codegraphpackage and you do not need to use the fork — justnpm install -g @colbymchenry/codegraphand runcodegraph initin your project.If the PR is still pending, follow the fork instructions below.
The upstream PR (colbymchenry/codegraph#627) is pending review. In the meantime you can run the fork directly.
Download from nodejs.org if you don't have it.
git clone https://github.com/Michael2150/codegraph
cd codegraph
npm install
npm run buildGo to the v1.0.1 release and download the binary for your platform:
| Platform | File to download |
|---|---|
| Windows | codegraph-roslyn-win-x64.exe |
| macOS Intel | codegraph-roslyn-osx-x64 |
| macOS Apple Silicon | codegraph-roslyn-osx-arm64 |
| Linux | codegraph-roslyn-linux-x64 |
Place it in the bin/ folder inside the cloned repo, keeping the exact filename.
On macOS/Linux you also need to make it executable:
chmod +x bin/codegraph-roslyn-osx-arm64# From inside the codegraph fork directory
node dist/bin/codegraph.js init /path/to/your/vb/projectThat's it. codegraph will index all .vb files using the Roslyn extractor and store the graph in .codegraph/ inside your project.
node dist/bin/codegraph.js serve --mcp --path /path/to/your/vb/projectOr install it into your agent by running:
node dist/bin/codegraph.js install- .NET 8 SDK
- Windows, macOS, or Linux
# Clone the repo
git clone https://github.com/your-fork/codegraph-roslyn
cd codegraph-roslyn
# Debug build (used during development and by the test suite)
dotnet build
# The binary lands at:
# src/CodeGraph.Roslyn/bin/Debug/net8.0/codegraph-roslyn.exe (Windows)
# src/CodeGraph.Roslyn/bin/Debug/net8.0/codegraph-roslyn (macOS / Linux)# Windows
dotnet publish src/CodeGraph.Roslyn -r win-x64 -c Release \
-p:PublishSingleFile=true --self-contained true \
-o publish/win-x64
# macOS (Intel)
dotnet publish src/CodeGraph.Roslyn -r osx-x64 -c Release \
-p:PublishSingleFile=true --self-contained true \
-o publish/osx-x64
# Linux
dotnet publish src/CodeGraph.Roslyn -r linux-x64 -c Release \
-p:PublishSingleFile=true --self-contained true \
-o publish/linux-x64Copy the resulting binary into the codegraph fork's bin/ directory:
bin/
codegraph-roslyn-win-x64.exe
codegraph-roslyn-osx-x64
codegraph-roslyn-linux-x64
codegraph-roslyn --file <path-to-source-file>
Writes JSON to stdout. Writes errors to stderr. Exit code 0 on success.
# Example
codegraph-roslyn --file fixtures/VbFixture/GeometryTypes.vbOutput:
{
"nodes": [
{
"id": "C:/repo/GeometryTypes.vb::Fixtures::GeometryUtils",
"kind": "module",
"name": "GeometryUtils",
"qualifiedName": "Fixtures.GeometryUtils",
"filePath": "C:/repo/GeometryTypes.vb",
"startLine": 3,
"endLine": 20,
"visibility": "public",
"isStatic": false,
"isAsync": false,
"parentId": "C:/repo/GeometryTypes.vb::Fixtures"
}
],
"edges": [
{
"kind": "contains",
"fromId": "C:/repo/GeometryTypes.vb::Fixtures",
"toId": "C:/repo/GeometryTypes.vb::Fixtures::GeometryUtils",
"toQualifiedName": "Fixtures.GeometryUtils"
}
],
"unresolvedReferences": [],
"errors": []
}The fixtures/ directory contains small VB.NET and C# files that cover the node and edge types the extractor must handle. You can run the tool against any of them directly:
# After a debug build, point to the binary
export CODEGRAPH_ROSLYN_BIN=./src/CodeGraph.Roslyn/bin/Debug/net8.0/codegraph-roslyn
# Windows (PowerShell)
$env:CODEGRAPH_ROSLYN_BIN = ".\src\CodeGraph.Roslyn\bin\Debug\net8.0\codegraph-roslyn.exe"
# Run against a VB.NET fixture
$env:CODEGRAPH_ROSLYN_BIN --file fixtures/VbFixture/GeometryTypes.vb | python -m json.tool
# Run against a C# fixture
$env:CODEGRAPH_ROSLYN_BIN --file fixtures/CsFixture/GeometryTypes.cs | python -m json.toolAvailable fixtures:
| File | What it tests |
|---|---|
VbFixture/GeometryTypes.vb |
Module, classes, methods, fields, Overrides |
VbFixture/EventSystem.vb |
WithEvents, Handles, RaiseEvent, event handler wiring |
VbFixture/PartialClass.Part1.vb / Part2.vb |
Partial class across two files |
VbFixture/ImportAliases.vb |
Imports with aliases, nested namespaces |
VbFixture/AsyncPatterns.vb |
Async Sub (void async), Async Function, Await |
VbFixture/Animals.vb |
Inheritance (Inherits), Implements, qualified names |
CsFixture/GeometryTypes.cs |
Classes, structs, interfaces, generics |
CsFixture/EventSystem.cs |
Events, delegates, += wiring |
CsFixture/AsyncPatterns.cs |
async/await, Task<T> return types |
CsFixture/GenericTypes.cs |
Generic classes, constrained type parameters |
CsFixture/Animals.cs |
Inheritance chain, interface implementation, override |
CsFixture/ImportAliases.cs |
using aliases, nested namespaces |
The test suite is xUnit-based. Tests require the debug binary to exist and are skipped (not failed) when it is unavailable.
# 1. Build the extractor first
dotnet build
# 2. Set the binary path — must be an absolute path (the test process cwd differs from the repo root)
# macOS / Linux
export CODEGRAPH_ROSLYN_BIN="$(pwd)/src/CodeGraph.Roslyn/bin/Debug/net8.0/codegraph-roslyn"
# Windows (PowerShell)
$env:CODEGRAPH_ROSLYN_BIN = "$PWD\src\CodeGraph.Roslyn\bin\Debug\net8.0\codegraph-roslyn.exe"
# 3. Run the full suite
dotnet test
# Run only VB.NET tests
dotnet test tests/VbFixture.Tests
# Run only C# tests
dotnet test tests/CsFixture.Tests
# Run a specific test by name
dotnet test --filter "Module_IsExtractedWithKindModule"Expected output: 131 tests pass, 0 fail, 0 skip when CODEGRAPH_ROSLYN_BIN is set. All tests skip cleanly when the env var is absent (useful in CI before a binary build step).
codegraph-roslyn/
├── src/
│ └── CodeGraph.Roslyn/
│ ├── CodeGraph.Roslyn.csproj
│ ├── Program.cs # CLI entry point
│ ├── Models.cs # JSON output types
│ ├── CSharpExtractor.cs # C# syntax walker
│ └── VBNetExtractor.cs # VB.NET syntax walker
├── tests/
│ ├── CsFixture.Tests/ # xUnit tests for C# extraction
│ └── VbFixture.Tests/ # xUnit tests for VB.NET extraction
├── fixtures/
│ ├── CsFixture/ # C# source fixtures
│ └── VbFixture/ # VB.NET source fixtures
└── codegraph-roslyn.slnx # Solution file
codegraph's RoslynExtractor class (at src/extraction/roslyn-extractor.ts in the codegraph fork) invokes this binary as a subprocess via execFileSync, passing --file <path>. The JSON output is parsed and mapped to codegraph's internal Node, Edge, and UnresolvedReference types before being written to SQLite.
The binary is selected at runtime based on platform:
| Platform | Binary |
|---|---|
| Windows | bin/codegraph-roslyn-win-x64.exe |
| macOS | bin/codegraph-roslyn-osx-x64 |
| Linux | bin/codegraph-roslyn-linux-x64 |
During development, set CODEGRAPH_ROSLYN_BIN to override the path to the binary.