Skip to content
Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GraphCSharp

Visualize any C# codebase as an interactive D3 graph — drop one GitHub Action into your repo.

CIReleaseLicense.NET 8Stars

→ Open the live demo

Demo

What it does

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.

30-second example

Add .github/workflows/code-graph.yml to your repo:

name: Generate Code Graphon:
push:
branches: [main]permissions:
contents: writejobs:
graph:
runs-on: ubuntu-lateststeps:
- uses: TheSmallPixel/GraphCSharp@v1with:
source-path: ./srcdocs-dir: docscommit-changes: 'true'

Then enable GitHub Pages on the docs/ folder. Your live graph appears at https://<user>.github.io/<repo>/.

Inputs

NameDefaultDescription
source-path./srcDirectory scanned recursively for .cs files.
docs-dirdocsWhere graph.json and index.html are written.
index-fileindex.htmlVisualizer HTML filename. Copied from this action if missing.
commit-changesfalseWhen true, commits the generated graph back to your repo.

Links

How it works

  1. The action checks out your repo and provisions .NET 8.
  2. Builds the Roslyn-based analyzer in tools/CodeAnalysisTool.
  3. Walks every .cs file under source-path, emitting nodes (namespaces, classes, methods, properties) and links (containment, calls, inheritance, type usage) as docs/graph.json.
  4. Drops a D3 visualizer into docs/index.html if one isn't already there.
  5. Optionally commits both files back so GitHub Pages serves a fresh graph on every push.

Development

Requires the .NET 8 SDK.

git clone https://github.com/TheSmallPixel/GraphCSharp
cd GraphCSharp
dotnet test tools/CodeAnalysisTool.Tests/CodeAnalysisTool.Tests.csproj

To run the analyzer against any folder of .cs files:

dotnet run --project tools/CodeAnalysisTool -- <source-path> ./docs

Open docs/index.html to inspect the result locally.

License

MIT — see LICENSE.

About

Visualize any C# codebase as an interactive D3 graph — drop one GitHub Action into your repo.

Topics

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages