RSCG_ExportDiagram by AndreiIgnat
Nuget / site data
Details
Info
info
Name: RSCG_ExportDiagram
Roslyn Diagram generator for external dependencies
Author: AndreiIgnat
NuGet: https://github.com/ignatandrei/RSCG_ExportDiagram
You can find more details at RSCG_ExportDiagram
Original Readme
note
RSCG_ExportDiagram
export diagram for external relations for a csproj with other csproj
Install
Add to the csproj
<ItemGroup>
<PackageReference Include="RSCG_ExportDiagram" Version="2024.810.832" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
<ItemGroup>
<CompilerVisibleProperty Include="RSCG_ExportDiagram_OutputFolder" />
<CompilerVisibleProperty Include="RSCG_ExportDiagram_Exclude" />
</ItemGroup>
<PropertyGroup>
<RSCG_ExportDiagram_OutputFolder>..</RSCG_ExportDiagram_OutputFolder>
<RSCG_ExportDiagram_Exclude></RSCG_ExportDiagram_Exclude>
</PropertyGroup>
And the diagram will be generated in the folder parent for the .csproj file
Alternatively, you can use the command line tool to generate the diagram for a solution
function ProcessCsproj {
param (
[string]$project,
[string]$folderOutput
)
$version = "2024.810.832"
#$folderOutput= ".."
$newNode = [xml]@"
<MainData>
<ItemGroup>
<CompilerVisibleProperty Include="RSCG_ExportDiagram_OutputFolder" />
<CompilerVisibleProperty Include="RSCG_ExportDiagram_Exclude" />
</ItemGroup>
<PropertyGroup>
<RSCG_ExportDiagram_OutputFolder>$folderOutput</RSCG_ExportDiagram_OutputFolder>
<RSCG_ExportDiagram_Exclude></RSCG_ExportDiagram_Exclude>
</PropertyGroup>
</MainData>
"@
# Write-Host $newNode.MainData.InnerXml
$backFile =$project + ".bak"
Copy-Item $project $backFile
dotnet add $project package RSCG_ExportDiagram -v $version
$proj = [xml](Get-Content $project)
$foundNode = $proj.Project
#Write-Host $proj.Project.InnerXml
$ItemGroup = $proj.ImportNode($newNode.DocumentElement.ItemGroup,$true)
$proj.Project.PrependChild($ItemGroup)
$proj.DocumentElement.AppendChild($ItemGroup )
$PropertyGroup = $proj.ImportNode($newNode.DocumentElement.PropertyGroup,$true)
$proj.Project.PrependChild($PropertyGroup)
$proj.DocumentElement.AppendChild($PropertyGroup)
$proj.Save($project)
dotnet build
# pause
Copy-Item $backFile $project -Force
Remove-Item $backFile -Force
}
$solution = gci *.sln | %{ $_.FullName}
$folderSolution = Split-Path $solution
# Write-Host $folderSolution
Get-Content $solution |
Select-String 'Project\(' |
ForEach-Object {
$projectParts = $_ -Split '[,=]' | ForEach-Object { $_.Trim('[ "{}]') };
# New-Object PSObject -Property @{
# Name = $projectParts[1];
# File = $projectParts[2];
# Guid = $projectParts[3]
# }
if ($projectParts[2] -match '.csproj$'){
$fileProject =Join-Path $folderSolution $projectParts[2]
Write-Host $fileProject
ProcessCsproj -project $fileProject -folderOutput $folderSolution
}
}
About
note
Generating diagram for relation classes within referenced project
How to use
Example ( source csproj, source files )
- CSharp Project
- Program.cs
- PersonData.cs
This is the CSharp Project that references RSCG_ExportDiagram
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RSCG_ExportDiagram" Version="2024.810.832" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
<ItemGroup>
<CompilerVisibleProperty Include="RSCG_ExportDiagram_OutputFolder" />
<CompilerVisibleProperty Include="RSCG_ExportDiagram_Exclude" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Person\Person.csproj" />
</ItemGroup>
<PropertyGroup>
<RSCG_ExportDiagram_OutputFolder>obj/GX/</RSCG_ExportDiagram_OutputFolder>
<RSCG_ExportDiagram_Exclude></RSCG_ExportDiagram_Exclude>
</PropertyGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
</Project>
This is the use of RSCG_ExportDiagram in Program.cs
using Person;
internal class Program
{
private static void Main(string[] args)
{
PersonData person = new ();
person.Name = "Andrei Ignat";
Console.WriteLine(person.Name);
}
}
This is the use of RSCG_ExportDiagram in PersonData.cs
namespace Person;
public class PersonData
{
public string Name { get; set; }
public int Age { get; set; }
}
Generated Files
Those are taken from $(BaseIntermediateOutputPath)\GX
- DiagramDemoConsole_Program_1_gen.cs
- DiagramDemoConsole_rel_csproj.md
//JSONFolder=obj/GX/
//projectDir=D:\gth\RSCG_Examples\v2\rscg_examples\RSCG_ExportDiagram\src\DiagramDemo\DiagramDemoConsole\
//projectName=DiagramDemoConsole
//excludeData=
file class Program_References_1
{
public Program_References_1()
{
// Method Main has following external references
// Person.PersonData..ctor
//Person.PersonData.Name
}
}
Classes of DiagramDemoConsole
Class Program
Usefull
Download Example (.NET C# )
Share RSCG_ExportDiagram
https://ignatandrei.github.io/RSCG_Examples/v2/docs/RSCG_ExportDiagram