Visualize any C# codebase as an interactive D3 graph — drop one GitHub Action into your repo.
Reading C# architecture from a folder tree is slow. Roslyn can extract the real call graph, but wiring it up — analyzer, JSON schema, D3 layout, GitHub Pages — is a side-project of its own. GraphCSharp is that side-project, packaged as a single GitHub Action so any repo gets an interactive graph on every push.
Add .github/workflows/code-graph.yml to your repo:
name: Generate Code Graph
on:
push:
branches: [main]
permissions:
contents: write
jobs:
graph:
runs-on: ubuntu-latest
steps:
- uses: TheSmallPixel/GraphCSharp@v1
with:
source-path: ./src
docs-dir: docs
commit-changes: 'true'Then enable GitHub Pages on the docs/ folder. Your live graph appears at https://<user>.github.io/<repo>/.
| Name | Default | Description |
|---|---|---|
source-path |
./src |
Directory scanned recursively for .cs files. |
docs-dir |
docs |
Where graph.json and index.html are written. |
index-file |
index.html |
Visualizer HTML filename. Copied from this action if missing. |
commit-changes |
false |
When true, commits the generated graph back to your repo. |
- Live demo: https://thesmallpixel.github.io/GraphCSharp/
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- The action checks out your repo and provisions .NET 8.
- Builds the Roslyn-based analyzer in
tools/CodeAnalysisTool. - Walks every
.csfile undersource-path, emitting nodes (namespaces, classes, methods, properties) and links (containment, calls, inheritance, type usage) asdocs/graph.json. - Drops a D3 visualizer into
docs/index.htmlif one isn't already there. - Optionally commits both files back so GitHub Pages serves a fresh graph on every push.
Requires the .NET 8 SDK.
git clone https://github.com/TheSmallPixel/GraphCSharp
cd GraphCSharp
dotnet test tools/CodeAnalysisTool.Tests/CodeAnalysisTool.Tests.csprojTo run the analyzer against any folder of .cs files:
dotnet run --project tools/CodeAnalysisTool -- <source-path> ./docsOpen docs/index.html to inspect the result locally.
MIT — see LICENSE.