mcdg (Mermaid Class Diagram Generator) is a dotnet tool for generating mermaid.js class diagrams directly from C# source code (.cs files).
Unlike other tools that require compiled assemblies (DLLs), mcdg uses Roslyn to parse your source code files recursively from a directory. This allows you to generate diagrams for projects that may not currently build or to quickly visualize a folder of scripts.
This project is a source-code analysis port of dll2mmd.
The core graph generation logic and structure were originally written by rtfs, and this project adapts that logic to work with the Microsoft.CodeAnalysis (Roslyn) API instead of reflection.
-
Install .Net SDK 6.0 or later.
-
Install mcdg as a global dotnet tool.
$ dotnet tool install --global mcdg You can invoke the tool using the following command: mcdg Tool 'mcdg' (version '1.0.0') was successfully installed.
Alternatively, if running from source:
$ dotnet run --project src/MermaidClassDiagramGenerator/MermaidClassDiagramGenerator.csproj -- [options]
Description:
Generate mermaid.js class-diagram from C# source code files.
Usage:
mcdg [options]
Options:
-o, --output <output> Output file. [default: output.md]
-ns, --namespace <namespace> Namespace filter. []
-p, --path <path> (REQUIRED) Path to the folder containing .cs files.
-t, --type-names <type-names> Specific classes to include. []
--ignore-dependency If true, skip dependency arrows.
--version Show version information
-?, -h, --help Show help and usage information