Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,23 @@ classDiagram
MermaidGraph.NET --> mermaid-graph
class mermaid-graph{
type Exe
target net9.0
target net8.0;net9.0
}
class Nerdbank.GitVersioning{
type NuGet
version 3.7.115
}
mermaid-graph ..> Nerdbank.GitVersioning
class Microsoft.Build{
type NuGet
version 17.13.9
version 17.11.4
}
mermaid-graph ..> Microsoft.Build
class Microsoft.Build.Locator{
type NuGet
version 1.9.1
}
mermaid-graph ..> Microsoft.Build.Locator
class Microsoft.Build.Utilities.Core{
type NuGet
version 17.13.9
}
mermaid-graph ..> Microsoft.Build.Utilities.Core
class System.CommandLine.DragonFruit{
type NuGet
version 0.4.0-alpha.22272.1
Expand All @@ -79,6 +79,11 @@ classDiagram
target net9.0
}
MermaidGraphTests ..> mermaid-graph
class Nerdbank.GitVersioning{
type NuGet
version 3.7.115
}
MermaidGraphTests ..> Nerdbank.GitVersioning
class coverlet.collector{
type NuGet
version 6.0.4
Expand Down Expand Up @@ -129,4 +134,4 @@ classDiagram
version 5.0.0
}
MermaidGraphTests ..> NUnit3TestAdapter
```
```
4 changes: 2 additions & 2 deletions mermaid-graph/Diagrams/Base/MermaidDiagram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected MermaidDiagram()
/// <summary>
/// Initialize the graph output.
/// </summary>
public virtual void Header(string title)
internal virtual void Header(string title)
{
Graph.Clear();
Graph.AppendLine($"""
Expand All @@ -67,7 +67,7 @@ public virtual void Header(string title)
/// Get the mermaid diagram Markdown text.
/// </summary>
/// <returns>The contents of the graph buffer.</returns>
public override string ToString() => Graph.ToString();
public sealed override string ToString() => Graph.ToString();

/// <inheritdoc />
public virtual string Project(FileInfo file, string? filter = null, bool excludeNuget = false)
Expand Down
7 changes: 4 additions & 3 deletions mermaid-graph/Diagrams/ClassDiagram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace MermaidGraph.Diagrams;
public sealed class ClassDiagram : MermaidDiagram
{
/// <inheritdoc />
public override void Header(string title)
internal override void Header(string title)
{
base.Header(title);
Graph.AppendLine("classDiagram");
Expand Down Expand Up @@ -61,8 +61,9 @@ internal override void GraphProject(Project project, string? filter = null, bool
{
var projectName = Path.GetFileNameWithoutExtension(project.FullPath);
var type = project.GetPropertyValue("OutputType");
var targetFramework = project.GetPropertyValue("TargetFramework") ??
project.GetPropertyValue("TargetFrameworks");
var targetFramework = project.GetPropertyValue("TargetFramework");
if (string.IsNullOrEmpty(targetFramework))
targetFramework = project.GetPropertyValue("TargetFrameworks");

Graph.AppendLine($$"""
class {{projectName}}{
Expand Down
2 changes: 1 addition & 1 deletion mermaid-graph/Diagrams/GraphDiagram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace MermaidGraph.Diagrams;
public sealed class GraphDiagram : MermaidDiagram
{
/// <inheritdoc />
public override void Header(string title)
internal override void Header(string title)
{
base.Header(title);
Graph.AppendLine("graph TD");
Expand Down
4 changes: 2 additions & 2 deletions mermaid-graph/mermaid-graph.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<RootNamespace>MermaidGraph</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -63,7 +63,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="17.13.9" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build" Version="17.11.4" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.9.1" />
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.4.0-alpha.22272.1" />
</ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions mermaid-graphTests/CommandsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void DogFoodSolutionTest(DiagramType type, string typeName)

Console.WriteLine(graph);
Assert.That(graph, Is.Not.Null.Or.Empty, "Graph should not be null or empty.");
Assert.That(graph, Does.Contain($"title: {info.Name}"));
Assert.That(graph, Does.Contain("mermaid-graph"));
Assert.That(graph, Does.Contain("MermaidGraphTests"));
var graphType = DetectType(ExtractMermaid(graph));
Expand All @@ -74,6 +75,7 @@ public void DogFoodProjectTest(DiagramType type, string typeName)
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($"title: {info.Name}"));
Assert.That(graph, Does.Contain("mermaid-graph"));
Assert.That(graph, Does.Contain("MermaidGraphTests"));
Console.WriteLine(graph);
Expand Down
18 changes: 0 additions & 18 deletions mermaid-graphTests/MermaidDiagramTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,4 @@ public void GetDiagramType_ShouldThrowForUnsupportedType()
Assert.Throws<NotImplementedException>(()=>
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}"));
}
}

Loading