ProjGraph.Lib.ClassDiagram
1.0.1
dotnet add package ProjGraph.Lib.ClassDiagram --version 1.0.1
NuGet\Install-Package ProjGraph.Lib.ClassDiagram -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ProjGraph.Lib.ClassDiagram" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ProjGraph.Lib.ClassDiagram" Version="1.0.1" />
<PackageReference Include="ProjGraph.Lib.ClassDiagram" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ProjGraph.Lib.ClassDiagram --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ProjGraph.Lib.ClassDiagram, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ProjGraph.Lib.ClassDiagram@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ProjGraph.Lib.ClassDiagram&version=1.0.1
#tool nuget:?package=ProjGraph.Lib.ClassDiagram&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ProjGraph.Lib.ClassDiagram
Roslyn-powered class hierarchy analysis and Mermaid class diagram generation for .NET projects.
Installation
dotnet add package ProjGraph.Lib.ClassDiagram
Overview
ProjGraph.Lib.ClassDiagram uses the Roslyn workspace API to analyze C# source code and generate
Mermaid class diagrams. It supports:
- Analyzing individual
.csfiles or entire project workspaces - Extracting classes, records, interfaces, abstract types, enums, and structs
- Capturing fields, properties, methods, and their visibility modifiers
- Detecting inheritance, implementation, and composition relationships
- Configurable member visibility filters
Usage
Register all services:
using ProjGraph.Lib.Core;
using ProjGraph.Lib.ClassDiagram;
services.AddProjGraphCore();
services.AddProjGraphClassDiagram();
Generate a class diagram from a project
using ProjGraph.Lib.ClassDiagram.Application;
using ProjGraph.Lib.ClassDiagram.Application.UseCases;
var analysisService = provider.GetRequiredService<IClassAnalysisService>();
var result = await analysisService.AnalyzeAsync("src/MyProject/MyProject.csproj", new AnalysisOptions
{
IncludePrivateMembers = false,
IncludeInternalTypes = false
});
var renderer = provider.GetRequiredService<MermaidClassDiagramRenderer>();
string diagram = renderer.Render(result);
Example output:
classDiagram
class OrderService {
+PlaceOrder(request OrderRequest) Task~Order~
+CancelOrder(id Guid) Task
}
class IOrderRepository {
<<interface>>
+FindById(id Guid) Task~Order~
}
OrderService --> IOrderRepository
Analyze a single file or directory
var analyzeFile = provider.GetRequiredService<AnalyzeFileUseCase>();
var result = await analyzeFile.ExecuteAsync("src/Domain/Order.cs");
var analyzeDirectory = provider.GetRequiredService<AnalyzeDirectoryUseCase>();
var result = await analyzeDirectory.ExecuteAsync("src/Domain/");
Key Services
| Service | Description |
|---|---|
IClassAnalysisService |
Orchestrates full Roslyn workspace analysis |
AnalyzeFileUseCase |
Analyzes a single C# source file |
AnalyzeDirectoryUseCase |
Analyzes all .cs files in a directory |
MermaidClassDiagramRenderer |
Renders analysis results as a Mermaid class diagram |
Links
- GitHub Repository
- Documentation
- CLI tool —
projgraph classdiagram
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.CodeAnalysis.Workspaces.MSBuild (>= 5.3.0)
- ProjGraph.Lib.Core (>= 1.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ProjGraph.Lib.ClassDiagram:
| Package | Downloads |
|---|---|
|
ProjGraph.Lib
Meta-package that bundles all ProjGraph libraries: project graph, class diagram, and Entity Framework analysis with a single DI registration. |
GitHub repositories
This package is not used by any popular GitHub repositories.