Skip to content

Commit a1f1daa

Browse files
committed
Revert "feat: add graph initialization and refactor graph generation methods in DependencyGraphGenerator"
This reverts commit 40785ac.
1 parent 40785ac commit a1f1daa

2 files changed

Lines changed: 22 additions & 16 deletions

File tree

CodeLineCounter.Tests/DependencyGraphGeneratorTests.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,6 @@ public void enclose_string_in_quotes_returns_quoted_null_for_null_input()
111111
Assert.Equal(string.Empty, result);
112112
}
113113

114-
// Setting graph properties after initialization
115-
[Fact]
116-
public void initialize_graph_should_set_correct_graph_properties()
117-
{
118-
DotGraph graph;
119-
120-
DependencyGraphGenerator.InitializeGraph(out graph);
121-
122-
Assert.Equal("DependencyGraph", graph.Label.Value);
123-
Assert.Equal("DependencyGraph", graph.Identifier.Value);
124-
}
125-
126114

127115
}
128116
}

CodeLineCounter/Services/DependencyGraphGenerator.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static DotGraph GenerateGraphOnly(List<DependencyRelation> dependencies,
3636

3737
foreach (var vertex in nsGroup.Value)
3838
{
39-
DotNode node = CreateNode(vertexInfo, vertex);
39+
DotNode node = CreateNode(vertexInfo, EncloseNotEmptyOrNullStringInQuotes(vertex));
4040

4141
cluster.Elements.Add(node);
4242
}
@@ -60,8 +60,8 @@ private static DotEdge CreateEdge(DependencyRelation dep)
6060
var targetLabel = dep.TargetClass;
6161

6262
var edge = new DotEdge();
63-
var dotIdentifierFrom = new DotIdentifier(sourceLabel);
64-
var dotIdentifierTo = new DotIdentifier(targetLabel);
63+
var dotIdentifierFrom = new DotIdentifier(EncloseNotEmptyOrNullStringInQuotes(sourceLabel));
64+
var dotIdentifierTo = new DotIdentifier(EncloseNotEmptyOrNullStringInQuotes(targetLabel));
6565

6666
edge.From = dotIdentifierFrom;
6767
edge.To = dotIdentifierTo;
@@ -82,7 +82,7 @@ private static DotSubgraph CreateCluster(KeyValuePair<string, List<string>> nsGr
8282

8383
public static DotNode CreateNode(Dictionary<string, (int incoming, int outgoing)> vertexInfo, string vertex)
8484
{
85-
var info = vertexInfo[vertex];
85+
var info = vertexInfo[RemoveQuotes(vertex) ?? vertex];
8686
var node = new DotNode();
8787
node.WithIdentifier(vertex, true);
8888
node.Label = $"{vertex}" + Environment.NewLine + $"\nIn: {info.incoming}, Out: {info.outgoing}";
@@ -183,5 +183,23 @@ private static List<DependencyRelation> FilterNamespaceFromDependencies(List<Dep
183183
return filteredDependencies;
184184
}
185185

186+
public static string EncloseNotEmptyOrNullStringInQuotes(string? str)
187+
{
188+
if (!string.IsNullOrEmpty(str))
189+
{
190+
return $"\"{str}\"";
191+
}
192+
else
193+
{
194+
return string.Empty;
195+
}
196+
197+
}
198+
199+
public static string RemoveQuotes(string str)
200+
{
201+
return str.Replace("\"", "");
202+
}
203+
186204
}
187205
}

0 commit comments

Comments
 (0)