From fae77514928857cef8c6e55db66c605745dba33d Mon Sep 17 00:00:00 2001
From: Adam Kauffman <26984068+A9G-Data-Droid@users.noreply.github.com>
Date: Tue, 29 Apr 2025 20:00:49 -0700
Subject: [PATCH 1/7] Consolidate
- Refactor
- Change scope to be more appropriate
- DRY
- More tests
---
MermaidGraph.NET.sln | 1 +
mermaid-graph/Commands.cs | 13 ++-----
.../Diagrams/{ => Base}/DiagramType.cs | 2 +-
.../Diagrams/{ => Base}/IMermaidDiagram.cs | 2 +-
.../Diagrams/{ => Base}/MermaidDiagram.cs | 39 +++++++++++++++++--
mermaid-graph/Diagrams/ClassDiagram.cs | 27 ++++---------
mermaid-graph/Diagrams/GraphDiagram.cs | 27 ++++---------
mermaid-graph/Program.cs | 2 +-
mermaid-graphTests/CommandsTests.cs | 2 +-
mermaid-graphTests/MermaidDiagramTests.cs | 31 +++++++++++++++
10 files changed, 88 insertions(+), 58 deletions(-)
rename mermaid-graph/Diagrams/{ => Base}/DiagramType.cs (87%)
rename mermaid-graph/Diagrams/{ => Base}/IMermaidDiagram.cs (95%)
rename mermaid-graph/Diagrams/{ => Base}/MermaidDiagram.cs (51%)
create mode 100644 mermaid-graphTests/MermaidDiagramTests.cs
diff --git a/MermaidGraph.NET.sln b/MermaidGraph.NET.sln
index 6b48d6c..8083d5e 100644
--- a/MermaidGraph.NET.sln
+++ b/MermaidGraph.NET.sln
@@ -8,6 +8,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C33AF3DC-C3F9-45B6-828C-57CB2B60EC96}"
ProjectSection(SolutionItems) = preProject
MermaidGraph.NET.md = MermaidGraph.NET.md
+ .github\workflows\publish.yml = .github\workflows\publish.yml
README.md = README.md
EndProjectSection
EndProject
diff --git a/mermaid-graph/Commands.cs b/mermaid-graph/Commands.cs
index 32e3547..c8cfbb6 100644
--- a/mermaid-graph/Commands.cs
+++ b/mermaid-graph/Commands.cs
@@ -1,4 +1,4 @@
-using MermaidGraph.Diagrams;
+using MermaidGraph.Diagrams.Base;
namespace MermaidGraph;
@@ -14,7 +14,7 @@ public class Commands
///
public static string Project(FileInfo file, DiagramType diagramType = DiagramType.Graph)
{
- var graph = GetGraphType(diagramType);
+ var graph = MermaidDiagram.GetDiagramType(diagramType);
return graph.Project(file);
}
@@ -26,15 +26,8 @@ public static string Project(FileInfo file, DiagramType diagramType = DiagramTyp
///
public static string Solution(FileInfo file, DiagramType diagramType = DiagramType.Graph)
{
- var graph = GetGraphType(diagramType);
+ var graph = MermaidDiagram.GetDiagramType(diagramType);
return graph.Solution(file);
}
-
- private static IMermaidDiagram GetGraphType(DiagramType diagramType) => diagramType switch
- {
- DiagramType.Class => new ClassDiagram(),
- DiagramType.Graph => new GraphDiagram(),
- _ => throw new NotImplementedException($"Option not supported: {diagramType}"),
- };
}
\ No newline at end of file
diff --git a/mermaid-graph/Diagrams/DiagramType.cs b/mermaid-graph/Diagrams/Base/DiagramType.cs
similarity index 87%
rename from mermaid-graph/Diagrams/DiagramType.cs
rename to mermaid-graph/Diagrams/Base/DiagramType.cs
index d580ec6..d422c57 100644
--- a/mermaid-graph/Diagrams/DiagramType.cs
+++ b/mermaid-graph/Diagrams/Base/DiagramType.cs
@@ -1,4 +1,4 @@
-namespace MermaidGraph.Diagrams;
+namespace MermaidGraph.Diagrams.Base;
///
/// Specifies the type of mermaid diagram to generate.
diff --git a/mermaid-graph/Diagrams/IMermaidDiagram.cs b/mermaid-graph/Diagrams/Base/IMermaidDiagram.cs
similarity index 95%
rename from mermaid-graph/Diagrams/IMermaidDiagram.cs
rename to mermaid-graph/Diagrams/Base/IMermaidDiagram.cs
index d9c6221..3637af2 100644
--- a/mermaid-graph/Diagrams/IMermaidDiagram.cs
+++ b/mermaid-graph/Diagrams/Base/IMermaidDiagram.cs
@@ -1,4 +1,4 @@
-namespace MermaidGraph.Diagrams;
+namespace MermaidGraph.Diagrams.Base;
///
/// This file defines the IMermaidDiagram interface and the MermaidDiagram abstract class.
diff --git a/mermaid-graph/Diagrams/MermaidDiagram.cs b/mermaid-graph/Diagrams/Base/MermaidDiagram.cs
similarity index 51%
rename from mermaid-graph/Diagrams/MermaidDiagram.cs
rename to mermaid-graph/Diagrams/Base/MermaidDiagram.cs
index 8aeebdc..cddd1e4 100644
--- a/mermaid-graph/Diagrams/MermaidDiagram.cs
+++ b/mermaid-graph/Diagrams/Base/MermaidDiagram.cs
@@ -1,7 +1,8 @@
using System.Text;
+using Microsoft.Build.Evaluation;
using Microsoft.Build.Locator;
-namespace MermaidGraph.Diagrams;
+namespace MermaidGraph.Diagrams.Base;
///
/// The MermaidDiagram abstract class implements shared functionality for Mermaid diagram generation,
@@ -19,7 +20,7 @@ public abstract class MermaidDiagram : IMermaidDiagram
///
public const string MermaidBegin = Fence + "mermaid";
- internal readonly StringBuilder Graph = new();
+ internal readonly StringBuilder Graph = new(256);
///
/// Initialize the MermaidDiagram class and ensure MSBuild is registered.
@@ -32,14 +33,27 @@ protected MermaidDiagram()
}
}
+ ///
+ /// Factory method to get the appropriate graph type based on the provided DiagramType enum value.
+ ///
+ /// The type of graph to generate.
+ /// The appropriate methods for generating a diagram of that type.
+ /// If an enum type is added without corresponding diagram class.
+ public static IMermaidDiagram GetDiagramType(DiagramType diagramType) => diagramType switch
+ {
+ DiagramType.Class => new ClassDiagram(),
+ DiagramType.Graph => new GraphDiagram(),
+ _ => throw new NotImplementedException($"Option not supported: {diagramType}"),
+ };
+
///
/// Initialize the graph output.
///
public virtual void Header(string title)
{
Graph.Clear();
- Graph.AppendLine(MermaidBegin);
Graph.AppendLine($"""
+ {MermaidBegin}
---
title: {title}
config:
@@ -56,8 +70,25 @@ public virtual void Header(string title)
public override string ToString() => Graph.ToString();
///
- public abstract string Project(FileInfo file);
+ public virtual string Project(FileInfo file)
+ {
+ Header(file.Name);
+ using var projectCollection = new ProjectCollection();
+ var project = projectCollection.LoadProject(file.FullName);
+ GraphProject(project);
+ Graph.AppendLine(Fence);
+
+ projectCollection.UnloadAllProjects();
+
+ return Graph.ToString();
+ }
///
public abstract string Solution(FileInfo file);
+
+ ///
+ /// This method must be implemented in all derived classes to generate the graph for a project.
+ ///
+ /// A project to graph.
+ internal abstract void GraphProject(Project project);
}
diff --git a/mermaid-graph/Diagrams/ClassDiagram.cs b/mermaid-graph/Diagrams/ClassDiagram.cs
index f69e09f..30b7a06 100644
--- a/mermaid-graph/Diagrams/ClassDiagram.cs
+++ b/mermaid-graph/Diagrams/ClassDiagram.cs
@@ -1,9 +1,13 @@
-using Microsoft.Build.Construction;
+using MermaidGraph.Diagrams.Base;
+using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
namespace MermaidGraph.Diagrams;
-internal class ClassDiagram : MermaidDiagram
+///
+/// Generates a Mermaid class diagram.
+///
+public sealed class ClassDiagram : MermaidDiagram
{
///
public override void Header(string title)
@@ -12,23 +16,6 @@ public override void Header(string title)
Graph.AppendLine("classDiagram");
}
- ///
- /// Generate the dependency graph of a Visual Studio Project.
- ///
- /// `.csproj` file.
- public override string Project(FileInfo file)
- {
- Header(file.Name);
- using var projectCollection = new ProjectCollection();
- var project = projectCollection.LoadProject(file.FullName);
- GraphProject(project);
- Graph.AppendLine(Fence);
-
- projectCollection.UnloadAllProjects();
-
- return Graph.ToString();
- }
-
///
/// Generate the dependency graph of a Visual Studio Solution.
///
@@ -69,7 +56,7 @@ type solution
return Graph.ToString();
}
- private void GraphProject(Project project)
+ internal override void GraphProject(Project project)
{
var projectName = Path.GetFileNameWithoutExtension(project.FullPath);
var type = project.GetPropertyValue("OutputType");
diff --git a/mermaid-graph/Diagrams/GraphDiagram.cs b/mermaid-graph/Diagrams/GraphDiagram.cs
index 809a36a..cb24a3a 100644
--- a/mermaid-graph/Diagrams/GraphDiagram.cs
+++ b/mermaid-graph/Diagrams/GraphDiagram.cs
@@ -1,9 +1,13 @@
-using Microsoft.Build.Construction;
+using MermaidGraph.Diagrams.Base;
+using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
namespace MermaidGraph.Diagrams;
-internal class GraphDiagram : MermaidDiagram
+///
+/// Generates a Mermaid dependency graph for Visual Studio projects and solutions.
+///
+public sealed class GraphDiagram : MermaidDiagram
{
///
public override void Header(string title)
@@ -12,23 +16,6 @@ public override void Header(string title)
Graph.AppendLine("graph TD");
}
- ///
- /// Generate the dependency graph of a Visual Studio Project.
- ///
- /// `.csproj` file.
- public override string Project(FileInfo file)
- {
- Header(file.Name);
- using var projectCollection = new ProjectCollection();
- var project = projectCollection.LoadProject(file.FullName);
- GraphProject(project);
- Graph.AppendLine(Fence);
-
- projectCollection.UnloadAllProjects();
-
- return Graph.ToString();
- }
-
///
/// Generate the dependency graph of a Visual Studio Solution.
///
@@ -64,7 +51,7 @@ public override string Solution(FileInfo file)
return Graph.ToString();
}
- private void GraphProject(Project project)
+ internal override void GraphProject(Project project)
{
var projectName = Path.GetFileNameWithoutExtension(project.FullPath);
diff --git a/mermaid-graph/Program.cs b/mermaid-graph/Program.cs
index 4a52f4d..0976109 100644
--- a/mermaid-graph/Program.cs
+++ b/mermaid-graph/Program.cs
@@ -1,4 +1,4 @@
-using MermaidGraph.Diagrams;
+using MermaidGraph.Diagrams.Base;
namespace MermaidGraph;
diff --git a/mermaid-graphTests/CommandsTests.cs b/mermaid-graphTests/CommandsTests.cs
index 1ec7da0..5dbbaf9 100644
--- a/mermaid-graphTests/CommandsTests.cs
+++ b/mermaid-graphTests/CommandsTests.cs
@@ -1,4 +1,4 @@
-using MermaidGraph.Diagrams;
+using MermaidGraph.Diagrams.Base;
using Microsoft.ClearScript.V8;
using NUnit.Framework;
using Assert = NUnit.Framework.Assert;
diff --git a/mermaid-graphTests/MermaidDiagramTests.cs b/mermaid-graphTests/MermaidDiagramTests.cs
new file mode 100644
index 0000000..ec44e4d
--- /dev/null
+++ b/mermaid-graphTests/MermaidDiagramTests.cs
@@ -0,0 +1,31 @@
+using MermaidGraph.Diagrams;
+using MermaidGraph.Diagrams.Base;
+using NUnit.Framework;
+using Assert = NUnit.Framework.Assert;
+
+namespace MermaidGraph.Tests;
+
+[TestFixture]
+public class MermaidDiagramTests
+{
+ [Test]
+ public void GetDiagramType_ShouldReturnCorrectInstance()
+ {
+ // Arrange & Act
+ var classDiagram = MermaidDiagram.GetDiagramType(DiagramType.Class);
+ var graphDiagram = MermaidDiagram.GetDiagramType(DiagramType.Graph);
+
+ // Assert
+ Assert.That(classDiagram, Is.TypeOf());
+ Assert.That(graphDiagram, Is.TypeOf());
+ }
+
+ [Test]
+ public void GetDiagramType_ShouldThrowForUnsupportedType()
+ {
+ // Arrange & Act
+ Assert.Throws(()=>
+ MermaidDiagram.GetDiagramType((DiagramType)999));
+ }
+}
+
From 95442409858853ee2e9f7b9f73155c44effbd681 Mon Sep 17 00:00:00 2001
From: Adam Kauffman <26984068+A9G-Data-Droid@users.noreply.github.com>
Date: Tue, 29 Apr 2025 20:46:51 -0700
Subject: [PATCH 2/7] Add name filtering
Improve tests
---
mermaid-graph/Commands.cs | 12 +++----
.../Diagrams/Base/IMermaidDiagram.cs | 6 ++--
mermaid-graph/Diagrams/Base/MermaidDiagram.cs | 11 +++---
mermaid-graph/Diagrams/ClassDiagram.cs | 25 ++++++++-----
mermaid-graph/Diagrams/GraphDiagram.cs | 19 ++++++----
mermaid-graph/Program.cs | 7 ++--
mermaid-graphTests/CommandsTests.cs | 35 +++++++++++++++++--
mermaid-graphTests/MermaidDiagramTests.cs | 17 +++++++++
8 files changed, 95 insertions(+), 37 deletions(-)
diff --git a/mermaid-graph/Commands.cs b/mermaid-graph/Commands.cs
index c8cfbb6..43eb5f8 100644
--- a/mermaid-graph/Commands.cs
+++ b/mermaid-graph/Commands.cs
@@ -10,24 +10,20 @@ public class Commands
///
/// Generate the dependency graph of a Visual Studio Project.
///
- /// `.csproj` file.
- ///
- public static string Project(FileInfo file, DiagramType diagramType = DiagramType.Graph)
+ public static string Project(FileInfo file, DiagramType diagramType = DiagramType.Graph, string? filter = null)
{
var graph = MermaidDiagram.GetDiagramType(diagramType);
- return graph.Project(file);
+ return graph.Project(file, filter);
}
///
/// Generate the dependency graph of a Visual Studio Solution.
///
- /// `.sln` file.
- ///
- public static string Solution(FileInfo file, DiagramType diagramType = DiagramType.Graph)
+ public static string Solution(FileInfo file, DiagramType diagramType = DiagramType.Graph, string? filter = null)
{
var graph = MermaidDiagram.GetDiagramType(diagramType);
- return graph.Solution(file);
+ return graph.Solution(file, filter);
}
}
\ No newline at end of file
diff --git a/mermaid-graph/Diagrams/Base/IMermaidDiagram.cs b/mermaid-graph/Diagrams/Base/IMermaidDiagram.cs
index 3637af2..7c23423 100644
--- a/mermaid-graph/Diagrams/Base/IMermaidDiagram.cs
+++ b/mermaid-graph/Diagrams/Base/IMermaidDiagram.cs
@@ -11,13 +11,15 @@ public interface IMermaidDiagram
/// Generate the diagram from a visual studio project file (*.csproj)
///
/// The project file
+ /// Exclude projects whose name matches the filter. (e.g., Test)
/// Mermaid Markdown
- public string Project(FileInfo file);
+ public string Project(FileInfo file, string? filter = null);
///
/// Generate the diagram from a visual studio solution file (*.sln)
///
/// The solution file.
+ /// Exclude projects whose name matches the filter. (e.g., Test)
/// Mermaid Markdown
- public string Solution(FileInfo file);
+ public string Solution(FileInfo file, string? filter = null);
}
\ No newline at end of file
diff --git a/mermaid-graph/Diagrams/Base/MermaidDiagram.cs b/mermaid-graph/Diagrams/Base/MermaidDiagram.cs
index cddd1e4..ddf3157 100644
--- a/mermaid-graph/Diagrams/Base/MermaidDiagram.cs
+++ b/mermaid-graph/Diagrams/Base/MermaidDiagram.cs
@@ -20,7 +20,7 @@ public abstract class MermaidDiagram : IMermaidDiagram
///
public const string MermaidBegin = Fence + "mermaid";
- internal readonly StringBuilder Graph = new(256);
+ internal StringBuilder Graph { get; } = new(256);
///
/// Initialize the MermaidDiagram class and ensure MSBuild is registered.
@@ -70,12 +70,12 @@ public virtual void Header(string title)
public override string ToString() => Graph.ToString();
///
- public virtual string Project(FileInfo file)
+ public virtual string Project(FileInfo file, string? filter = null)
{
Header(file.Name);
using var projectCollection = new ProjectCollection();
var project = projectCollection.LoadProject(file.FullName);
- GraphProject(project);
+ GraphProject(project, filter);
Graph.AppendLine(Fence);
projectCollection.UnloadAllProjects();
@@ -84,11 +84,12 @@ public virtual string Project(FileInfo file)
}
///
- public abstract string Solution(FileInfo file);
+ public abstract string Solution(FileInfo file, string? filter = null);
///
/// This method must be implemented in all derived classes to generate the graph for a project.
///
/// A project to graph.
- internal abstract void GraphProject(Project project);
+ /// Exclude projects whose name matches the filter. (e.g., Test)
+ internal abstract void GraphProject(Project project, string? filter = null);
}
diff --git a/mermaid-graph/Diagrams/ClassDiagram.cs b/mermaid-graph/Diagrams/ClassDiagram.cs
index 30b7a06..8d19f78 100644
--- a/mermaid-graph/Diagrams/ClassDiagram.cs
+++ b/mermaid-graph/Diagrams/ClassDiagram.cs
@@ -16,11 +16,8 @@ public override void Header(string title)
Graph.AppendLine("classDiagram");
}
- ///
- /// Generate the dependency graph of a Visual Studio Solution.
- ///
- /// `.sln` file.
- public override string Solution(FileInfo file)
+ ///
+ public override string Solution(FileInfo file, string? filter = null)
{
Header(file.Name);
var solutionFile = SolutionFile.Parse(file.FullName);
@@ -37,15 +34,19 @@ type solution
foreach (var project in solutionFile.ProjectsInOrder)
{
if (project.ProjectType != SolutionProjectType.KnownToBeMSBuildFormat) continue;
-
+
var projectPath = project.AbsolutePath;
var projectName = Path.GetFileNameWithoutExtension(projectPath);
+ if (!string.IsNullOrEmpty(filter) &&
+ projectName.Contains(filter, StringComparison.Ordinal))
+ continue;
+
Graph.AppendLine($" {solutionId} --> {projectName}");
var projectFile = new FileInfo(projectPath);
if (projectFile.Exists)
{
var referenceProject = projectCollection.LoadProject(projectFile.FullName);
- GraphProject(referenceProject);
+ GraphProject(referenceProject, filter);
}
}
@@ -56,11 +57,13 @@ type solution
return Graph.ToString();
}
- internal override void GraphProject(Project project)
+ internal override void GraphProject(Project project, string? filter = null)
{
var projectName = Path.GetFileNameWithoutExtension(project.FullPath);
var type = project.GetPropertyValue("OutputType");
- var targetFramework = project.GetPropertyValue("TargetFramework") ?? project.GetPropertyValue("TargetFrameworks");
+ var targetFramework = project.GetPropertyValue("TargetFramework") ??
+ project.GetPropertyValue("TargetFrameworks");
+
Graph.AppendLine($$"""
class {{projectName}}{
type {{type}}
@@ -72,6 +75,10 @@ class {{projectName}}{
{
var refPath = item.EvaluatedInclude;
var refName = Path.GetFileNameWithoutExtension(refPath);
+ if (!string.IsNullOrEmpty(filter) &&
+ projectName.Contains(filter, StringComparison.Ordinal))
+ continue;
+
Graph.AppendLine($" {projectName} ..> {refName}");
}
diff --git a/mermaid-graph/Diagrams/GraphDiagram.cs b/mermaid-graph/Diagrams/GraphDiagram.cs
index cb24a3a..8443aa9 100644
--- a/mermaid-graph/Diagrams/GraphDiagram.cs
+++ b/mermaid-graph/Diagrams/GraphDiagram.cs
@@ -16,11 +16,8 @@ public override void Header(string title)
Graph.AppendLine("graph TD");
}
- ///
- /// Generate the dependency graph of a Visual Studio Solution.
- ///
- /// `.sln` file.
- public override string Solution(FileInfo file)
+ ///
+ public override string Solution(FileInfo file, string? filter = null)
{
Header(file.Name);
var solutionFile = SolutionFile.Parse(file.FullName);
@@ -35,12 +32,16 @@ public override string Solution(FileInfo file)
var projectPath = project.AbsolutePath;
var projectName = Path.GetFileNameWithoutExtension(projectPath);
+ if (!string.IsNullOrEmpty(filter) &&
+ projectName.Contains(filter, StringComparison.Ordinal))
+ continue;
+
Graph.AppendLine($" {solutionId} --> {projectName}");
var projectFile = new FileInfo(projectPath);
if (projectFile.Exists)
{
var referenceProject = projectCollection.LoadProject(projectFile.FullName);
- GraphProject(referenceProject);
+ GraphProject(referenceProject, filter);
}
}
@@ -51,7 +52,7 @@ public override string Solution(FileInfo file)
return Graph.ToString();
}
- internal override void GraphProject(Project project)
+ internal override void GraphProject(Project project, string? filter = null)
{
var projectName = Path.GetFileNameWithoutExtension(project.FullPath);
@@ -59,6 +60,10 @@ internal override void GraphProject(Project project)
{
var refPath = item.EvaluatedInclude;
var refName = Path.GetFileNameWithoutExtension(refPath);
+ if (!string.IsNullOrEmpty(filter) &&
+ projectName.Contains(filter, StringComparison.Ordinal))
+ continue;
+
Graph.AppendLine($" {projectName} --> {refName}");
}
diff --git a/mermaid-graph/Program.cs b/mermaid-graph/Program.cs
index 0976109..a7b5a18 100644
--- a/mermaid-graph/Program.cs
+++ b/mermaid-graph/Program.cs
@@ -12,8 +12,9 @@ public sealed class Program
///
/// Full path to the solution (*.sln) or project (*.csproj) file that will be mapped.
/// The type of diagram to generate (e.g., Graph or Class).
+ /// Exclude projects whose name matches the filter. (e.g., Test)
/// HResult
- public static int Main(string? path, DiagramType type = DiagramType.Graph)
+ public static int Main(string? path, DiagramType type = DiagramType.Graph, string? filter = null)
{
if (path is null)
{
@@ -34,13 +35,13 @@ public static int Main(string? path, DiagramType type = DiagramType.Graph)
{
if (path.EndsWith(".csproj"))
{
- Console.WriteLine(Commands.Project(file, type));
+ Console.WriteLine(Commands.Project(file, type, filter));
return 0;
}
if (path.EndsWith(".sln"))
{
- Console.WriteLine(Commands.Solution(file, type));
+ Console.WriteLine(Commands.Solution(file, type, filter));
return 0;
}
}
diff --git a/mermaid-graphTests/CommandsTests.cs b/mermaid-graphTests/CommandsTests.cs
index 5dbbaf9..afa100c 100644
--- a/mermaid-graphTests/CommandsTests.cs
+++ b/mermaid-graphTests/CommandsTests.cs
@@ -29,6 +29,12 @@ private V8ScriptEngine Js {
new object[] { DiagramType.Graph, "flowchart" }
];
+ internal static readonly object[] FilterTestCases =
+ [
+ new object[] { DiagramType.Class, "Test" },
+ new object[] { DiagramType.Graph, "Test" }
+ ];
+
[OneTimeTearDown]
public void Disposal()
{
@@ -46,10 +52,13 @@ public void DogFoodSolutionTest(DiagramType type, string typeName)
var graph = Commands.Solution(info, type);
Console.WriteLine(graph);
-
+ Assert.That(graph, Is.Not.Null.Or.Empty, "Graph should not be null or empty.");
+ Assert.That(graph, Does.Contain("mermaid-graph"));
+ Assert.That(graph, Does.Contain("MermaidGraphTests"));
var graphType = DetectType(ExtractMermaid(graph));
+ Console.WriteLine($"Detected type: {graphType}");
+
Assert.That(graphType, Is.EqualTo(typeName));
- Console.WriteLine(graphType);
}
[Test]
@@ -61,7 +70,9 @@ public void DogFoodProjectTest(DiagramType type, string typeName)
var info = new FileInfo(filePath!);
Assert.That(info.Exists);
var graph = Commands.Project(info, type);
-
+ Assert.That(graph, Is.Not.Null.Or.Empty, "Graph should not be null or empty.");
+ Assert.That(graph, Does.Contain("mermaid-graph"));
+ Assert.That(graph, Does.Contain("MermaidGraphTests"));
Console.WriteLine(graph);
var graphType = DetectType(ExtractMermaid(graph));
@@ -97,6 +108,24 @@ public void CommandLineFailTests(string? file, int hResult)
Assert.That(Program.Main(file), Is.EqualTo(hResult));
}
+ [Test]
+ [TestCaseSource(nameof(FilterTestCases))]
+ public void DiagramsShouldNotContainFilteredContent(DiagramType type, string filter)
+ {
+ var solutionPath = FindFileDownTree("*.sln");
+ Assert.That(solutionPath, Is.Not.Null);
+ var info = new FileInfo(solutionPath!);
+ Assert.That(info.Exists);
+ var graph = Commands.Solution(info, type);
+ Assert.That(graph, Does.Contain(filter),
+ $"Original Graph should contain filtered content: {filter}");
+
+ graph = Commands.Solution(info, type, filter);
+ Console.WriteLine(graph);
+ Assert.That(graph, Does.Not.Contain(filter),
+ $"Graph should not contain filtered content: {filter}");
+ }
+
private static string ExtractMermaid(string? markup)
{
Assert.That(markup, Does.StartWith(MermaidDiagram.MermaidBegin));
diff --git a/mermaid-graphTests/MermaidDiagramTests.cs b/mermaid-graphTests/MermaidDiagramTests.cs
index ec44e4d..8c94e30 100644
--- a/mermaid-graphTests/MermaidDiagramTests.cs
+++ b/mermaid-graphTests/MermaidDiagramTests.cs
@@ -27,5 +27,22 @@ public void GetDiagramType_ShouldThrowForUnsupportedType()
Assert.Throws(()=>
MermaidDiagram.GetDiagramType((DiagramType)999));
}
+
+ [Test]
+ [TestCase(DiagramType.Class)]
+ [TestCase(DiagramType.Graph)]
+ public void Header_ShouldInitializeGraphWithTitle(DiagramType type)
+ {
+ var diagram = (MermaidDiagram)MermaidDiagram.GetDiagramType(type);
+
+ // Arrange
+ const string title = "Test Diagram";
+
+ // Act
+ diagram.Header(title);
+
+ // Assert
+ Assert.That(diagram.ToString(), Does.Contain($"title: {title}"));
+ }
}
From e6bbf2a3e46bca5bb447b0a15eb4505d465a50f4 Mon Sep 17 00:00:00 2001
From: Adam Kauffman <26984068+A9G-Data-Droid@users.noreply.github.com>
Date: Tue, 29 Apr 2025 21:07:43 -0700
Subject: [PATCH 3/7] Enable PackageValidationBaselineVersion
Update all dependencies
---
mermaid-graph/mermaid-graph.csproj | 10 ++++------
mermaid-graphTests/MermaidGraphTests.csproj | 12 ++++++------
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/mermaid-graph/mermaid-graph.csproj b/mermaid-graph/mermaid-graph.csproj
index aead51d..8098b1a 100644
--- a/mermaid-graph/mermaid-graph.csproj
+++ b/mermaid-graph/mermaid-graph.csproj
@@ -29,9 +29,7 @@
1.0.0
LICENSE
true
-
-
-
+ 1.0.0
@@ -64,9 +62,9 @@
-
-
-
+
+
+
diff --git a/mermaid-graphTests/MermaidGraphTests.csproj b/mermaid-graphTests/MermaidGraphTests.csproj
index 4d3de3d..baad2b3 100644
--- a/mermaid-graphTests/MermaidGraphTests.csproj
+++ b/mermaid-graphTests/MermaidGraphTests.csproj
@@ -17,17 +17,17 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
-
-
+
+
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
From b235ca27426f8a8c5ed37218704671da968cf439 Mon Sep 17 00:00:00 2001
From: Adam Kauffman <26984068+A9G-Data-Droid@users.noreply.github.com>
Date: Tue, 29 Apr 2025 21:48:14 -0700
Subject: [PATCH 4/7] Update README
Add nerdback versioning for 1.1
---
Directory.Build.props | 9 +++++++++
MermaidGraph.NET.md | 25 ++++++++++++++++++-------
MermaidGraph.NET.sln | 1 +
README.md | 21 +++++++++++----------
mermaid-graph/mermaid-graph.csproj | 5 +++--
version.json | 13 +++++++++++++
6 files changed, 55 insertions(+), 19 deletions(-)
create mode 100644 Directory.Build.props
create mode 100644 version.json
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 0000000..e638e40
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,9 @@
+
+
+
+
+ all
+ 3.7.115
+
+
+
\ No newline at end of file
diff --git a/MermaidGraph.NET.md b/MermaidGraph.NET.md
index 39c755c..1f4031c 100644
--- a/MermaidGraph.NET.md
+++ b/MermaidGraph.NET.md
@@ -16,17 +16,17 @@ classDiagram
}
class Microsoft.Build{
type NuGet
- version 17.12.6
+ version 17.13.9
}
mermaid-graph ..> Microsoft.Build
class Microsoft.Build.Locator{
type NuGet
- version 1.7.8
+ version 1.9.1
}
mermaid-graph ..> Microsoft.Build.Locator
class Microsoft.Build.Utilities.Core{
type NuGet
- version 17.12.6
+ version 17.13.9
}
mermaid-graph ..> Microsoft.Build.Utilities.Core
class System.CommandLine.DragonFruit{
@@ -50,6 +50,16 @@ classDiagram
version 6.0.4
}
MermaidGraphTests ..> coverlet.msbuild
+ class Microsoft.ClearScript.V8{
+ type NuGet
+ version 7.5.0
+ }
+ MermaidGraphTests ..> Microsoft.ClearScript.V8
+ class Microsoft.ClearScript.V8.Native.win-x64{
+ type NuGet
+ version 7.5.0
+ }
+ MermaidGraphTests ..> Microsoft.ClearScript.V8.Native.win-x64
class Microsoft.NET.Test.Sdk{
type NuGet
version 17.13.0
@@ -57,12 +67,12 @@ classDiagram
MermaidGraphTests ..> Microsoft.NET.Test.Sdk
class MSTest.TestAdapter{
type NuGet
- version 3.7.3
+ version 3.8.3
}
MermaidGraphTests ..> MSTest.TestAdapter
class MSTest.TestFramework{
type NuGet
- version 3.7.3
+ version 3.8.3
}
MermaidGraphTests ..> MSTest.TestFramework
class NUnit{
@@ -72,12 +82,13 @@ classDiagram
MermaidGraphTests ..> NUnit
class NUnit.Analyzers{
type NuGet
- version 4.6.0
+ version 4.7.0
}
MermaidGraphTests ..> NUnit.Analyzers
class NUnit3TestAdapter{
type NuGet
- version 4.3.2
+ version 5.0.0
}
MermaidGraphTests ..> NUnit3TestAdapter
```
+
diff --git a/MermaidGraph.NET.sln b/MermaidGraph.NET.sln
index 8083d5e..987ece0 100644
--- a/MermaidGraph.NET.sln
+++ b/MermaidGraph.NET.sln
@@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
MermaidGraph.NET.md = MermaidGraph.NET.md
.github\workflows\publish.yml = .github\workflows\publish.yml
README.md = README.md
+ version.json = version.json
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MermaidGraphTests", "mermaid-graphTests\MermaidGraphTests.csproj", "{FADD9D23-431E-4C1B-B2D4-D4FDF0674FCA}"
diff --git a/README.md b/README.md
index 4afac30..61c84e0 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
Create a mermaid graph of the dependency diagram for a project, or whole solution.
-## Dotnet tool [](https://www.nuget.org/packages/mermaid-graph/)
+## Dotnet tool [](https://www.nuget.org/packages/mermaid-graph/)
You can install as a dotnet tool so you can easily map all of your software projects:
@@ -21,6 +21,7 @@ Usage:
Options:
--path Full path to the solution (*.sln) or project (*.csproj) file that will be mapped.
--type The type of diagram to generate (e.g., Graph or Class). [default: Graph]
+ --filter Exclude projects whose name matches the filter. (e.g., Test) []
--version Show version information
-?, -h, --help Show help and usage information
```
@@ -53,17 +54,17 @@ classDiagram
}
class Microsoft.Build{
type NuGet
- version 17.12.6
+ version 17.13.9
}
mermaid-graph ..> Microsoft.Build
class Microsoft.Build.Locator{
type NuGet
- version 1.7.8
+ version 1.9.1
}
mermaid-graph ..> Microsoft.Build.Locator
class Microsoft.Build.Utilities.Core{
type NuGet
- version 17.12.6
+ version 17.13.9
}
mermaid-graph ..> Microsoft.Build.Utilities.Core
class System.CommandLine.DragonFruit{
@@ -89,12 +90,12 @@ classDiagram
MermaidGraphTests ..> coverlet.msbuild
class Microsoft.ClearScript.V8{
type NuGet
- version 7.4.5
+ version 7.5.0
}
MermaidGraphTests ..> Microsoft.ClearScript.V8
class Microsoft.ClearScript.V8.Native.win-x64{
type NuGet
- version 7.4.5
+ version 7.5.0
}
MermaidGraphTests ..> Microsoft.ClearScript.V8.Native.win-x64
class Microsoft.NET.Test.Sdk{
@@ -104,12 +105,12 @@ classDiagram
MermaidGraphTests ..> Microsoft.NET.Test.Sdk
class MSTest.TestAdapter{
type NuGet
- version 3.7.3
+ version 3.8.3
}
MermaidGraphTests ..> MSTest.TestAdapter
class MSTest.TestFramework{
type NuGet
- version 3.7.3
+ version 3.8.3
}
MermaidGraphTests ..> MSTest.TestFramework
class NUnit{
@@ -119,12 +120,12 @@ classDiagram
MermaidGraphTests ..> NUnit
class NUnit.Analyzers{
type NuGet
- version 4.6.0
+ version 4.7.0
}
MermaidGraphTests ..> NUnit.Analyzers
class NUnit3TestAdapter{
type NuGet
- version 4.3.2
+ version 5.0.0
}
MermaidGraphTests ..> NUnit3TestAdapter
```
diff --git a/mermaid-graph/mermaid-graph.csproj b/mermaid-graph/mermaid-graph.csproj
index 8098b1a..bc086c2 100644
--- a/mermaid-graph/mermaid-graph.csproj
+++ b/mermaid-graph/mermaid-graph.csproj
@@ -22,14 +22,15 @@
https://github.com/A9G-Data-Droid/MermaidGraph.NET.git
mermaid.js
en
- $(AssemblyVersion)
+ $(Version)
True
mermaid-graph.png
mermaid-graph.ico
- 1.0.0
+ 1.1.0
LICENSE
true
1.0.0
+ $(Version)
diff --git a/version.json b/version.json
new file mode 100644
index 0000000..255fb87
--- /dev/null
+++ b/version.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
+ "version": "1.1",
+ "publicReleaseRefSpec": [
+ "^refs/heads/master$",
+ "^refs/heads/v\\d+(?:\\.\\d+)?$"
+ ],
+ "cloudBuild": {
+ "buildNumber": {
+ "enabled": true
+ }
+ }
+}
\ No newline at end of file
From bbd9d2ae571871ffdbb868f7f6fad94b73cf7d95 Mon Sep 17 00:00:00 2001
From: Adam Kauffman <26984068+A9G-Data-Droid@users.noreply.github.com>
Date: Tue, 29 Apr 2025 22:22:28 -0700
Subject: [PATCH 5/7] Implement --noNuget
---
mermaid-graph/Commands.cs | 8 +--
.../Diagrams/Base/IMermaidDiagram.cs | 6 +-
mermaid-graph/Diagrams/Base/MermaidDiagram.cs | 9 +--
mermaid-graph/Diagrams/ClassDiagram.cs | 7 ++-
mermaid-graph/Diagrams/GraphDiagram.cs | 7 ++-
mermaid-graph/Program.cs | 9 +--
mermaid-graph/mermaid-graph.csproj | 1 -
mermaid-graphTests/CommandsTests.cs | 62 ++++++++++++++++++-
mermaid-graphTests/MermaidDiagramTests.cs | 1 +
mermaid-graphTests/MermaidGraphTests.csproj | 13 +++-
10 files changed, 100 insertions(+), 23 deletions(-)
diff --git a/mermaid-graph/Commands.cs b/mermaid-graph/Commands.cs
index 43eb5f8..911812d 100644
--- a/mermaid-graph/Commands.cs
+++ b/mermaid-graph/Commands.cs
@@ -10,20 +10,20 @@ public class Commands
///
/// Generate the dependency graph of a Visual Studio Project.
///
- public static string Project(FileInfo file, DiagramType diagramType = DiagramType.Graph, string? filter = null)
+ public static string Project(FileInfo file, DiagramType diagramType = DiagramType.Graph, string? filter = null, bool excludeNuget = false)
{
var graph = MermaidDiagram.GetDiagramType(diagramType);
- return graph.Project(file, filter);
+ return graph.Project(file, filter, excludeNuget);
}
///
/// Generate the dependency graph of a Visual Studio Solution.
///
- public static string Solution(FileInfo file, DiagramType diagramType = DiagramType.Graph, string? filter = null)
+ public static string Solution(FileInfo file, DiagramType diagramType = DiagramType.Graph, string? filter = null, bool excludeNuget = false)
{
var graph = MermaidDiagram.GetDiagramType(diagramType);
- return graph.Solution(file, filter);
+ return graph.Solution(file, filter, excludeNuget);
}
}
\ No newline at end of file
diff --git a/mermaid-graph/Diagrams/Base/IMermaidDiagram.cs b/mermaid-graph/Diagrams/Base/IMermaidDiagram.cs
index 7c23423..5bf2f6f 100644
--- a/mermaid-graph/Diagrams/Base/IMermaidDiagram.cs
+++ b/mermaid-graph/Diagrams/Base/IMermaidDiagram.cs
@@ -12,14 +12,16 @@ public interface IMermaidDiagram
///
/// The project file
/// Exclude projects whose name matches the filter. (e.g., Test)
+ /// Do not include NuGet packages in the graph
/// Mermaid Markdown
- public string Project(FileInfo file, string? filter = null);
+ public string Project(FileInfo file, string? filter = null, bool excludeNuget = false);
///
/// Generate the diagram from a visual studio solution file (*.sln)
///
/// The solution file.
/// Exclude projects whose name matches the filter. (e.g., Test)
+ /// Do not include NuGet packages in the graph
/// Mermaid Markdown
- public string Solution(FileInfo file, string? filter = null);
+ public string Solution(FileInfo file, string? filter = null, bool excludeNuget = false);
}
\ No newline at end of file
diff --git a/mermaid-graph/Diagrams/Base/MermaidDiagram.cs b/mermaid-graph/Diagrams/Base/MermaidDiagram.cs
index ddf3157..2ba3073 100644
--- a/mermaid-graph/Diagrams/Base/MermaidDiagram.cs
+++ b/mermaid-graph/Diagrams/Base/MermaidDiagram.cs
@@ -70,12 +70,12 @@ public virtual void Header(string title)
public override string ToString() => Graph.ToString();
///
- public virtual string Project(FileInfo file, string? filter = null)
+ public virtual string Project(FileInfo file, string? filter = null, bool excludeNuget = false)
{
Header(file.Name);
using var projectCollection = new ProjectCollection();
var project = projectCollection.LoadProject(file.FullName);
- GraphProject(project, filter);
+ GraphProject(project, filter, excludeNuget);
Graph.AppendLine(Fence);
projectCollection.UnloadAllProjects();
@@ -84,12 +84,13 @@ public virtual string Project(FileInfo file, string? filter = null)
}
///
- public abstract string Solution(FileInfo file, string? filter = null);
+ public abstract string Solution(FileInfo file, string? filter = null, bool excludeNuget = false);
///
/// This method must be implemented in all derived classes to generate the graph for a project.
///
/// A project to graph.
/// Exclude projects whose name matches the filter. (e.g., Test)
- internal abstract void GraphProject(Project project, string? filter = null);
+ /// Do not include NuGet packages in the graph
+ internal abstract void GraphProject(Project project, string? filter = null, bool excludeNuget = false);
}
diff --git a/mermaid-graph/Diagrams/ClassDiagram.cs b/mermaid-graph/Diagrams/ClassDiagram.cs
index 8d19f78..70b5645 100644
--- a/mermaid-graph/Diagrams/ClassDiagram.cs
+++ b/mermaid-graph/Diagrams/ClassDiagram.cs
@@ -17,7 +17,7 @@ public override void Header(string title)
}
///
- public override string Solution(FileInfo file, string? filter = null)
+ public override string Solution(FileInfo file, string? filter = null, bool excludeNuget = false)
{
Header(file.Name);
var solutionFile = SolutionFile.Parse(file.FullName);
@@ -46,7 +46,7 @@ type solution
if (projectFile.Exists)
{
var referenceProject = projectCollection.LoadProject(projectFile.FullName);
- GraphProject(referenceProject, filter);
+ GraphProject(referenceProject, filter, excludeNuget);
}
}
@@ -57,7 +57,7 @@ type solution
return Graph.ToString();
}
- internal override void GraphProject(Project project, string? filter = null)
+ internal override void GraphProject(Project project, string? filter = null, bool excludeNuget = false)
{
var projectName = Path.GetFileNameWithoutExtension(project.FullPath);
var type = project.GetPropertyValue("OutputType");
@@ -82,6 +82,7 @@ class {{projectName}}{
Graph.AppendLine($" {projectName} ..> {refName}");
}
+ if (excludeNuget) return;
foreach (var item in project.GetItems("PackageReference"))
{
var packageName = item.EvaluatedInclude;
diff --git a/mermaid-graph/Diagrams/GraphDiagram.cs b/mermaid-graph/Diagrams/GraphDiagram.cs
index 8443aa9..df91674 100644
--- a/mermaid-graph/Diagrams/GraphDiagram.cs
+++ b/mermaid-graph/Diagrams/GraphDiagram.cs
@@ -17,7 +17,7 @@ public override void Header(string title)
}
///
- public override string Solution(FileInfo file, string? filter = null)
+ public override string Solution(FileInfo file, string? filter = null, bool excludeNuget = false)
{
Header(file.Name);
var solutionFile = SolutionFile.Parse(file.FullName);
@@ -41,7 +41,7 @@ public override string Solution(FileInfo file, string? filter = null)
if (projectFile.Exists)
{
var referenceProject = projectCollection.LoadProject(projectFile.FullName);
- GraphProject(referenceProject, filter);
+ GraphProject(referenceProject, filter, excludeNuget);
}
}
@@ -52,7 +52,7 @@ public override string Solution(FileInfo file, string? filter = null)
return Graph.ToString();
}
- internal override void GraphProject(Project project, string? filter = null)
+ internal override void GraphProject(Project project, string? filter = null, bool excludeNuget = false)
{
var projectName = Path.GetFileNameWithoutExtension(project.FullPath);
@@ -67,6 +67,7 @@ internal override void GraphProject(Project project, string? filter = null)
Graph.AppendLine($" {projectName} --> {refName}");
}
+ if (excludeNuget) return;
foreach (var item in project.GetItems("PackageReference"))
{
var packageName = item.EvaluatedInclude;
diff --git a/mermaid-graph/Program.cs b/mermaid-graph/Program.cs
index a7b5a18..3c014b6 100644
--- a/mermaid-graph/Program.cs
+++ b/mermaid-graph/Program.cs
@@ -12,9 +12,10 @@ public sealed class Program
///
/// Full path to the solution (*.sln) or project (*.csproj) file that will be mapped.
/// The type of diagram to generate (e.g., Graph or Class).
- /// Exclude projects whose name matches the filter. (e.g., Test)
+ /// Exclude projects whose name matches the filter. (e.g., Test).
+ /// Do not include NuGet packages in the graph.
/// HResult
- public static int Main(string? path, DiagramType type = DiagramType.Graph, string? filter = null)
+ public static int Main(string? path, DiagramType type = DiagramType.Graph, string? filter = null, bool noNuget = false)
{
if (path is null)
{
@@ -35,13 +36,13 @@ public static int Main(string? path, DiagramType type = DiagramType.Graph, strin
{
if (path.EndsWith(".csproj"))
{
- Console.WriteLine(Commands.Project(file, type, filter));
+ Console.WriteLine(Commands.Project(file, type, filter, noNuget));
return 0;
}
if (path.EndsWith(".sln"))
{
- Console.WriteLine(Commands.Solution(file, type, filter));
+ Console.WriteLine(Commands.Solution(file, type, filter, noNuget));
return 0;
}
}
diff --git a/mermaid-graph/mermaid-graph.csproj b/mermaid-graph/mermaid-graph.csproj
index bc086c2..69c7706 100644
--- a/mermaid-graph/mermaid-graph.csproj
+++ b/mermaid-graph/mermaid-graph.csproj
@@ -65,7 +65,6 @@
-
diff --git a/mermaid-graphTests/CommandsTests.cs b/mermaid-graphTests/CommandsTests.cs
index afa100c..1252a0c 100644
--- a/mermaid-graphTests/CommandsTests.cs
+++ b/mermaid-graphTests/CommandsTests.cs
@@ -1,4 +1,7 @@
-using MermaidGraph.Diagrams.Base;
+using System;
+using System.IO;
+using System.Linq;
+using MermaidGraph.Diagrams.Base;
using Microsoft.ClearScript.V8;
using NUnit.Framework;
using Assert = NUnit.Framework.Assert;
@@ -126,6 +129,63 @@ public void DiagramsShouldNotContainFilteredContent(DiagramType type, string fil
$"Graph should not contain filtered content: {filter}");
}
+ [Test]
+ [TestCase(DiagramType.Graph)]
+ [TestCase(DiagramType.Class)]
+ public void Project_ShouldExcludeNuget_WhenExcludeNugetIsTrue(DiagramType type)
+ {
+ var filePath = FindFileDownTree("*.csproj");
+ Assert.That(filePath, Is.Not.Null);
+ var info = new FileInfo(filePath!);
+ Assert.That(info.Exists);
+
+ var graph = Commands.Project(info, type, excludeNuget: true);
+ Assert.That(graph, Does.Not.Contain("NuGet"), "Graph should not contain NuGet references when noNuget is true.");
+ }
+
+ [Test]
+ [TestCase(DiagramType.Graph)]
+ [TestCase(DiagramType.Class)]
+ public void Solution_ShouldExcludeNuget_WhenExcludeNugetIsTrue(DiagramType type)
+ {
+ var solutionPath = FindFileDownTree("*.sln");
+ Assert.That(solutionPath, Is.Not.Null);
+ var info = new FileInfo(solutionPath!);
+ Assert.That(info.Exists);
+
+ var graph = Commands.Solution(info, type, excludeNuget: true);
+ Assert.That(graph, Does.Not.Contain("NuGet"), "Graph should not contain NuGet references when noNuget is true.");
+ }
+
+ [Test]
+ [TestCase(DiagramType.Graph)]
+ [TestCase(DiagramType.Class)]
+ public void Project_ShouldIncludeNuget_WhenExcludeNugetIsFalse(DiagramType type)
+ {
+ var filePath = FindFileDownTree("*.csproj");
+ Assert.That(filePath, Is.Not.Null);
+ var info = new FileInfo(filePath!);
+ Assert.That(info.Exists);
+
+ var graph = Commands.Project(info, type, excludeNuget: false);
+ Assert.That(graph, Does.Contain("NuGet"), "Graph should contain NuGet references when noNuget is false.");
+ }
+
+ [Test]
+ [TestCase(DiagramType.Graph)]
+ [TestCase(DiagramType.Class)]
+ public void Solution_ShouldIncludeNuget_WhenExcludeNugetIsFalse(DiagramType type)
+ {
+ var solutionPath = FindFileDownTree("*.sln");
+ Assert.That(solutionPath, Is.Not.Null);
+ var info = new FileInfo(solutionPath!);
+ Assert.That(info.Exists);
+
+ var graph = Commands.Solution(info, type, excludeNuget: false);
+ Assert.That(graph, Does.Contain("NuGet"), "Graph should contain NuGet references when noNuget is false.");
+ }
+
+
private static string ExtractMermaid(string? markup)
{
Assert.That(markup, Does.StartWith(MermaidDiagram.MermaidBegin));
diff --git a/mermaid-graphTests/MermaidDiagramTests.cs b/mermaid-graphTests/MermaidDiagramTests.cs
index 8c94e30..90ea00a 100644
--- a/mermaid-graphTests/MermaidDiagramTests.cs
+++ b/mermaid-graphTests/MermaidDiagramTests.cs
@@ -1,3 +1,4 @@
+using System;
using MermaidGraph.Diagrams;
using MermaidGraph.Diagrams.Base;
using NUnit.Framework;
diff --git a/mermaid-graphTests/MermaidGraphTests.csproj b/mermaid-graphTests/MermaidGraphTests.csproj
index baad2b3..e11d4ec 100644
--- a/mermaid-graphTests/MermaidGraphTests.csproj
+++ b/mermaid-graphTests/MermaidGraphTests.csproj
@@ -4,8 +4,19 @@
net9.0
MermaidGraph.Tests
latest
- enable
+ disable
enable
+ True
+
+
+
+ 8
+ True
+
+
+
+ 8
+ True
From 33caa9b0a038b2fd084616ef971fdcf0258e9159 Mon Sep 17 00:00:00 2001
From: Adam Kauffman <26984068+A9G-Data-Droid@users.noreply.github.com>
Date: Tue, 29 Apr 2025 22:35:42 -0700
Subject: [PATCH 6/7] Add permissions to action yaml
Closes #6
---
.github/workflows/publish.yml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index e8308b2..2752677 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -1,6 +1,10 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: publish
+permissions:
+ contents: read
+ pull-requests: write
+
on:
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
push:
From b3796c7a3d7db3b989b1116daa41c6fe94236d79 Mon Sep 17 00:00:00 2001
From: Adam Kauffman <26984068+A9G-Data-Droid@users.noreply.github.com>
Date: Tue, 29 Apr 2025 22:46:28 -0700
Subject: [PATCH 7/7] Update readme with new option
---
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 61c84e0..97ec980 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,8 @@ Usage:
Options:
--path Full path to the solution (*.sln) or project (*.csproj) file that will be mapped.
--type The type of diagram to generate (e.g., Graph or Class). [default: Graph]
- --filter Exclude projects whose name matches the filter. (e.g., Test) []
+ --filter Exclude projects whose name matches the filter. (e.g., Test). []
+ --no-nuget Do not include NuGet packages in the graph. [default: False]
--version Show version information
-?, -h, --help Show help and usage information
```