-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
978 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using Microsoft.Msagl.Drawing; | ||
using Microsoft.Msagl.Layout.MDS; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NugetsDependencyGraph.CLI | ||
{ | ||
internal class GraphGenerator | ||
{ | ||
public string FileName { get; set; } | ||
|
||
public GraphGenerator(string fileName) | ||
{ | ||
FileName = fileName; | ||
} | ||
|
||
public void Generate(string targetFrameworks, string showOnlyDependenciesWithName, string limitToSingleProject, string colorSpecificDependency, string outputFolder) | ||
{ | ||
if (!File.Exists(FileName)) | ||
{ | ||
Console.WriteLine("File does not exist"); | ||
return; | ||
} | ||
Graph graph = new Graph("graph"); | ||
var json = File.ReadAllText(FileName); | ||
|
||
|
||
var jsonObject = JObject.Parse(json); | ||
var targets = jsonObject["targets"][targetFrameworks] as IDictionary<string, JToken>; | ||
if (targets == null) | ||
{ | ||
Console.WriteLine("Target does not exists"); | ||
return; | ||
} | ||
foreach (var target in targets) | ||
{ | ||
var nameVersion = target.Key.ToLower().Replace("/", ": "); | ||
if (!string.IsNullOrEmpty(showOnlyDependenciesWithName) && !nameVersion.Contains(showOnlyDependenciesWithName, | ||
StringComparison.InvariantCultureIgnoreCase)) | ||
{ | ||
continue; | ||
} | ||
Node node = null; | ||
if (string.IsNullOrEmpty(limitToSingleProject)) | ||
{ | ||
node = graph.AddNode(nameVersion); | ||
} | ||
else if (nameVersion.StartsWith(limitToSingleProject.ToLower())) | ||
{ | ||
node = graph.AddNode(nameVersion); | ||
node.Label.FontColor = Microsoft.Msagl.Drawing.Color.Green; | ||
node.Label.FontSize += 10; | ||
} | ||
|
||
if (!string.IsNullOrEmpty(colorSpecificDependency) && nameVersion.StartsWith(colorSpecificDependency.ToLower()) && node is not null) | ||
{ | ||
node.Label.FontColor = Microsoft.Msagl.Drawing.Color.DarkRed; | ||
node.Label.FontSize += 5; | ||
} | ||
var deps = target.Value["dependencies"] as IDictionary<string, JToken>; | ||
if (deps is null || node is null) | ||
{ | ||
continue; | ||
} | ||
foreach (var dep in deps) | ||
{ | ||
var dependent = dep.Key.ToLower() + ": " + (dep.Value as Newtonsoft.Json.Linq.JValue).Value; | ||
if (!string.IsNullOrEmpty(showOnlyDependenciesWithName) && !dependent.Contains(showOnlyDependenciesWithName, StringComparison.InvariantCultureIgnoreCase)) | ||
{ | ||
continue; | ||
} | ||
graph.AddNode(dependent); | ||
var edge = graph.AddEdge(nameVersion, dependent); | ||
edge.Attr.ArrowheadLength = 10; | ||
} | ||
} | ||
//bind the graph to the viewer | ||
graph.Attr.LayerDirection = LayerDirection.None; | ||
graph.Attr.OptimizeLabelPositions = true; | ||
graph.CreateLayoutSettings(); | ||
graph.LayoutAlgorithmSettings = new MdsLayoutSettings(); | ||
|
||
var renderer = new Microsoft.Msagl.GraphViewerGdi.GraphRenderer(graph); | ||
renderer.CalculateLayout(); | ||
|
||
var image = new Bitmap((int)(graph.Width * 2), (int)(graph.Height * 2)); | ||
renderer.Render(image); | ||
string outputFileName = Path.Join(outputFolder, "NugetDependencyGraphOutput.png"); | ||
image.Save(outputFileName, System.Drawing.Imaging.ImageFormat.Png); | ||
image.Dispose(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<PackAsTool>true</PackAsTool> | ||
<ToolCommandName>NugetsDependencyGraph</ToolCommandName> | ||
<PackageOutputPath>./nupkg</PackageOutputPath> | ||
<TargetFrameworks>net8.0-windows</TargetFrameworks> | ||
<RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<RootNamespace>NugetsDependencyGraph.CLI</RootNamespace> | ||
<AssemblyName>NugetsDependencyGraph.CLI</AssemblyName> | ||
<PackageId>NugetsDependencyGraph.CLI</PackageId> | ||
<Product>NugetsDependencyGraph</Product> | ||
<VersionPrefix>0.0.1.0</VersionPrefix> | ||
<VersionSuffix></VersionSuffix> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
<Description>cli tool fror creating nuget dependency graph</Description> | ||
<PackageReleaseNotes></PackageReleaseNotes> | ||
<PackageProjectUrl>https://github.com/LiorBanai/Nugets-Dependency-Graph</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/LiorBanai/Nugets-Dependency-Graph</RepositoryUrl> | ||
<Authors>Lior Banai</Authors> | ||
<Copyright>Lior Banai @ 2024</Copyright> | ||
<UseWindowsForms>true</UseWindowsForms> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" /> | ||
<PackageReference Include="Microsoft.Msagl" Version="1.1.6" /> | ||
<PackageReference Include="Microsoft.Msagl.Drawing" Version="1.1.6" /> | ||
<PackageReference Include="Microsoft.Msagl.GraphViewerGDI" Version="1.1.7" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | ||
<PackageReference Include="System.Drawing.Common" Version="8.0.7" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace NugetsDependencyGraph.CLI | ||
{ | ||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine("generating graph"); | ||
var filename =args[0]; | ||
var targetFramework = args[1];//"net8.0-windows7.0"; | ||
GraphGenerator graph = new GraphGenerator(filename); | ||
graph.Generate(targetFramework,"","","",Environment.CurrentDirectory); | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added
BIN
+175 KB
src/NugetsDependency.Winforms/bin/Debug/net8.0-windows/Microsoft.Msagl.Drawing.dll
Binary file not shown.
Binary file added
BIN
+181 KB
src/NugetsDependency.Winforms/bin/Debug/net8.0-windows/Microsoft.Msagl.GraphViewerGdi.dll
Binary file not shown.
Binary file added
BIN
+1.77 MB
src/NugetsDependency.Winforms/bin/Debug/net8.0-windows/Microsoft.Msagl.dll
Binary file not shown.
Binary file added
BIN
+696 KB
src/NugetsDependency.Winforms/bin/Debug/net8.0-windows/Newtonsoft.Json.dll
Binary file not shown.
113 changes: 113 additions & 0 deletions
113
src/NugetsDependency.Winforms/bin/Debug/net8.0-windows/NugetDependency.deps.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
{ | ||
"runtimeTarget": { | ||
"name": ".NETCoreApp,Version=v8.0", | ||
"signature": "" | ||
}, | ||
"compilationOptions": {}, | ||
"targets": { | ||
".NETCoreApp,Version=v8.0": { | ||
"NugetDependency/1.0.0": { | ||
"dependencies": { | ||
"Microsoft.CSharp": "4.7.0", | ||
"Microsoft.Msagl": "1.1.6", | ||
"Microsoft.Msagl.Drawing": "1.1.6", | ||
"Microsoft.Msagl.GraphViewerGDI": "1.1.7", | ||
"Newtonsoft.Json": "13.0.3", | ||
"System.Data.DataSetExtensions": "4.5.0" | ||
}, | ||
"runtime": { | ||
"NugetDependency.dll": {} | ||
} | ||
}, | ||
"Microsoft.CSharp/4.7.0": {}, | ||
"Microsoft.Msagl/1.1.6": { | ||
"runtime": { | ||
"lib/netstandard2.0/Microsoft.Msagl.dll": { | ||
"assemblyVersion": "0.0.0.0", | ||
"fileVersion": "0.0.0.0" | ||
} | ||
} | ||
}, | ||
"Microsoft.Msagl.Drawing/1.1.6": { | ||
"dependencies": { | ||
"Microsoft.Msagl": "1.1.6" | ||
}, | ||
"runtime": { | ||
"lib/netstandard2.0/Microsoft.Msagl.Drawing.dll": { | ||
"assemblyVersion": "0.0.0.0", | ||
"fileVersion": "0.0.0.0" | ||
} | ||
} | ||
}, | ||
"Microsoft.Msagl.GraphViewerGDI/1.1.7": { | ||
"dependencies": { | ||
"Microsoft.Msagl.Drawing": "1.1.6" | ||
}, | ||
"runtime": { | ||
"lib/net7.0-windows7.0/Microsoft.Msagl.GraphViewerGdi.dll": { | ||
"assemblyVersion": "0.0.0.0", | ||
"fileVersion": "0.0.0.0" | ||
} | ||
} | ||
}, | ||
"Newtonsoft.Json/13.0.3": { | ||
"runtime": { | ||
"lib/net6.0/Newtonsoft.Json.dll": { | ||
"assemblyVersion": "13.0.0.0", | ||
"fileVersion": "13.0.3.27908" | ||
} | ||
} | ||
}, | ||
"System.Data.DataSetExtensions/4.5.0": {} | ||
} | ||
}, | ||
"libraries": { | ||
"NugetDependency/1.0.0": { | ||
"type": "project", | ||
"serviceable": false, | ||
"sha512": "" | ||
}, | ||
"Microsoft.CSharp/4.7.0": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==", | ||
"path": "microsoft.csharp/4.7.0", | ||
"hashPath": "microsoft.csharp.4.7.0.nupkg.sha512" | ||
}, | ||
"Microsoft.Msagl/1.1.6": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-Fqxj+pmZEo/H2z/LEMFSmtt6GrSj2FKZfz15HhTQRhYRpdewFaC5mPIUxkzELJTac/hbUDb28QBjG/w0JbG2wg==", | ||
"path": "microsoft.msagl/1.1.6", | ||
"hashPath": "microsoft.msagl.1.1.6.nupkg.sha512" | ||
}, | ||
"Microsoft.Msagl.Drawing/1.1.6": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-xKEOHGDEzf1ulz7GISBxnjsqSl5+YhMhZ1I/UU7GMUkFtrwuShVg+irAZiZeK9VQRePXWeFWVhBlxrc3XulXNQ==", | ||
"path": "microsoft.msagl.drawing/1.1.6", | ||
"hashPath": "microsoft.msagl.drawing.1.1.6.nupkg.sha512" | ||
}, | ||
"Microsoft.Msagl.GraphViewerGDI/1.1.7": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-av6SIZxaNILJ2r0ALvRBppOPYNCkGr2OQTx6XhwpB4rwrHtvKpcP5Olj9Qj4Yq6ijthKkmmkhHkDk6MHfpqbtA==", | ||
"path": "microsoft.msagl.graphviewergdi/1.1.7", | ||
"hashPath": "microsoft.msagl.graphviewergdi.1.1.7.nupkg.sha512" | ||
}, | ||
"Newtonsoft.Json/13.0.3": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==", | ||
"path": "newtonsoft.json/13.0.3", | ||
"hashPath": "newtonsoft.json.13.0.3.nupkg.sha512" | ||
}, | ||
"System.Data.DataSetExtensions/4.5.0": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-221clPs1445HkTBZPL+K9sDBdJRB8UN8rgjO3ztB0CQ26z//fmJXtlsr6whGatscsKGBrhJl5bwJuKSA8mwFOw==", | ||
"path": "system.data.datasetextensions/4.5.0", | ||
"hashPath": "system.data.datasetextensions.4.5.0.nupkg.sha512" | ||
} | ||
} | ||
} |
Binary file added
BIN
+14.5 KB
src/NugetsDependency.Winforms/bin/Debug/net8.0-windows/NugetDependency.dll
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
src/NugetsDependency.Winforms/bin/Debug/net8.0-windows/NugetDependency.dll.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" /> | ||
</startup> | ||
</configuration> |
Binary file added
BIN
+140 KB
src/NugetsDependency.Winforms/bin/Debug/net8.0-windows/NugetDependency.exe
Binary file not shown.
Binary file added
BIN
+15.3 KB
src/NugetsDependency.Winforms/bin/Debug/net8.0-windows/NugetDependency.pdb
Binary file not shown.
18 changes: 18 additions & 0 deletions
18
src/NugetsDependency.Winforms/bin/Debug/net8.0-windows/NugetDependency.runtimeconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"runtimeOptions": { | ||
"tfm": "net8.0", | ||
"frameworks": [ | ||
{ | ||
"name": "Microsoft.NETCore.App", | ||
"version": "8.0.0" | ||
}, | ||
{ | ||
"name": "Microsoft.WindowsDesktop.App", | ||
"version": "8.0.0" | ||
} | ||
], | ||
"configProperties": { | ||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": true | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...pendency.Winforms/obj/Debug/net8.0-windows/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// <autogenerated /> | ||
using System; | ||
using System.Reflection; | ||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")] |
Binary file added
BIN
+180 Bytes
...pendency.Winforms/obj/Debug/net8.0-windows/NugetDependency.Properties.Resources.resources
Binary file not shown.
Oops, something went wrong.