Skip to content

EjafiSoftware/introspect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ejafi.Introspect CLI

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.

Requirements

  • .NET SDK 9.0 or later installed
  • A compiled .NET assembly to introspect (DLL or EXE)

Build

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 false

Run

You 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.

Usage

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 namespace blocks.

Examples

  • 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

Output

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
Loading

Render the output using Mermaid tooling (e.g., Mermaid CLI, VS Code Mermaid preview, or online Mermaid live editor).

Troubleshooting

  • "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.

About

A utility to visualize .NET assemblies

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages