Generate Mermaid class diagrams from compiled .NET assemblies.
This CLI loads a .NET assembly, builds a structural model of its types and members, and prints a Mermaid classDiagram to standard output. You can pipe or redirect the output to a .mmd file and render it with Mermaid-compatible tools.
- .NET SDK 9.0 or later installed
- A compiled .NET assembly to introspect (DLL or EXE)
From the repository root:
# Restore and build
dotnet build
# (Optional) Publish a self-contained executable
# Replace win-x64 with your RID if needed
dotnet publish src/Ejafi.Introspect.Cli -c Release -r win-x64 --self-contained falseYou can run the CLI without publishing using dotnet run:
# Basic usage (prints Mermaid to stdout)
dotnet run --project .\src\Ejafi.Introspect.Cli -- -a "/path/to/YourLibrary.dll"Or run the published binary from the publish output folder.
Ejafi.Introspect.Cli.exe [options] -a|--assembly <PATH>
Options:
- -a, --assembly (required)
- Path to the assembly file to introspect (DLL or EXE).
- -n, --namespace
- Group types by namespace. (Default: false)
- -p, --properties
- Include properties. (Default: true)
- -m, --methods
- Include methods. (Default: true)
- -f, --fields
- Include fields. (Default: false)
- --include-private
- Include private members (where applicable). (Default: false)
- --include-internal
- Include internal/protected-internal members (where applicable). (Default: false)
- --include-enums
- Include enum members (literals). (Default: true)
Notes:
- Properties and methods are included by default; fields are opt-in.
- "Group by namespace" wraps classes within Mermaid
namespaceblocks.
-
Basic diagram from an assembly:
dotnet run --project .\src\Ejafi.Introspect.Cli -- -a "/path/to/MyLib.dll"
-
Group by namespace and include fields:
dotnet run --project .\src\Ejafi.Introspect.Cli -- -a "/path/to/MyLib.dll" -n -f
-
Include private and internal members (where supported):
dotnet run --project .\src\Ejafi.Introspect.Cli -- -a "/path/to/MyLib.dll" --include-private --include-internal
-
Save to a Mermaid file for later rendering:
dotnet run --project .\src\Ejafi.Introspect.Cli -- -a "/path/to/MyLib.dll" > diagram.mmd
The CLI writes Mermaid class diagram syntax to stdout, beginning with classDiagram, followed by class/interface/enum blocks and relations (inheritance, implementation, association). Example snippet:
classDiagram
class Foo {
+ Bar Baz
+ Do(): void
}
Foo <|-- FooEx
Render the output using Mermaid tooling (e.g., Mermaid CLI, VS Code Mermaid preview, or online Mermaid live editor).
- "The file is not a valid .NET assembly": Ensure you point to a built .NET DLL/EXE targeting a compatible runtime.
- "Failed to load assembly": Make sure dependent assemblies are present next to the target assembly (or loadable from probing paths).
- Nothing printed: Verify the assembly actually contains types after any filters; also confirm stdout wasn’t redirected elsewhere.