KevinMarquette / PSGraph

A set of utilities for working with Graphviz in Powershell
MIT License
205 stars 49 forks source link

Parameter Attributes on edge cmdlet doesn't work in complex scenario #80

Closed Stephanevg closed 5 years ago

Stephanevg commented 5 years ago

Hi Kevin,

As discussed on Slack, find here some more details on the problem I am facing:

I am using PSClassUtils in order to create UML diagrams using PSGraph.

I am trying to set the arrow color of my edges from black (default) to white (none) in my diagrams.

I use the following function to actually genere the Graphviz code --> https://github.com/Stephanevg/PSClassUtils/blob/master/PsClassUtils/Functions/Private/Out-CUPSGraph.ps1

(The Edge are actually created at line 174)

edge -From $Child -To $Parent

I thought the change would be as simple as this:

edge -From $Child -To $Parent -Attributes @{arrowhead = "empty"}

or this

edge -From $Child -To $Parent -LiteralAttribute "[arrowhead="empty";]" 

But in both cases, the 'edge' section of the end of the graph, has never the corresponding graphviz data

I have tried using a complex, and more simple example, but in both cases, the data is simply not added:

Current behaviour

I use the code, to generate edges in my diagram:


#Line 174 from Out-CUPSGraph private function of PsClassUtils
edge -From $Child -To $Parent -Attributes @{arrowhead = "empty"}

but it generates:

Graphvizcode


digraph g {
    compound="true";
    subgraph cluster4867be98f6dd {
        label="Inheritance.ps1";
        "4867be98f6dd" [label="";style="invis";shape="point";]
        "Woop" [label=<<TABLE CELLBORDER="1" BORDER="0" CELLSPACING="0"><TR><TD bgcolor="black" align="center"><font color="white"><B>Woop</B></font></TD></TR><TR><TD PORT="Row_String" ALIGN="LEFT">+ [String] $String</TD></TR><TR><TD PORT="Row_number" ALIGN="LEFT">+ [int] $number</TD></TR><TR><TD PORT="Row_Separator_Constructors" ALIGN="LEFT">-----Constructors-----</TD></TR><TR><TD PORT="Row_Woop" ALIGN="LEFT"> Woop([String]$String,[int]$Number)</TD></TR><TR><TD PORT="Row_Separator_Methods" ALIGN="LEFT">-----Methods-----</TD></TR><TR><TD PORT="Row_DoSomething" ALIGN="LEFT">+[String] DoSomething()</TD></TR></TABLE>>;fillcolor="white";shape="none";style="filled";penwidth="1";fontname="Courier New";]
        "Wap" [label=<<TABLE CELLBORDER="1" BORDER="0" CELLSPACING="0"><TR><TD bgcolor="black" align="center"><font color="white"><B>Wap</B></font></TD></TR><TR><TD PORT="Row_prop3" ALIGN="LEFT">+ [String] $prop3</TD></TR><TR><TD PORT="Row_Separator_Constructors" ALIGN="LEFT">-----Constructors-----</TD></TR><TR><TD PORT="Row_Separator_Methods" ALIGN="LEFT">-----Methods-----</TD></TR><TR><TD PORT="Row_DoChildthing" ALIGN="LEFT">+ DoChildthing()</TD></TR></TABLE>>;fillcolor="white";shape="none";style="filled";penwidth="1";fontname="Courier New";]
        "Wep" [label=<<TABLE CELLBORDER="1" BORDER="0" CELLSPACING="0"><TR><TD bgcolor="black" align="center"><font color="white"><B>Wep</B></font></TD></TR><TR><TD PORT="Row_prop4" ALIGN="LEFT">+ [String] $prop4</TD></TR><TR><TD PORT="Row_Separator_Constructors" ALIGN="LEFT">-----Constructors-----</TD></TR><TR><TD PORT="Row_Separator_Methods" ALIGN="LEFT">-----Methods-----</TD></TR><TR><TD PORT="Row_DoOtherChildThing" ALIGN="LEFT">+ DoOtherChildThing()</TD></TR></TABLE>>;fillcolor="white";shape="none";style="filled";penwidth="1";fontname="Courier New";]
    }

    "Woop"->"Wap" 
    "Woop"->"Wep" 
}

Image

image

Expected Bahaviour

This is what I would expect to be generated

digraph g {
    compound="true";
    subgraph cluster4867be98f6dd {
        label="Inheritance.ps1";
        "4867be98f6dd" [label="";style="invis";shape="point";]
        "Woop" [label=<<TABLE CELLBORDER="1" BORDER="0" CELLSPACING="0"><TR><TD bgcolor="black" align="center"><font color="white"><B>Woop</B></font></TD></TR><TR><TD PORT="Row_String" ALIGN="LEFT">+ [String] $String</TD></TR><TR><TD PORT="Row_number" ALIGN="LEFT">+ [int] $number</TD></TR><TR><TD PORT="Row_Separator_Constructors" ALIGN="LEFT">-----Constructors-----</TD></TR><TR><TD PORT="Row_Woop" ALIGN="LEFT"> Woop([String]$String,[int]$Number)</TD></TR><TR><TD PORT="Row_Separator_Methods" ALIGN="LEFT">-----Methods-----</TD></TR><TR><TD PORT="Row_DoSomething" ALIGN="LEFT">+[String] DoSomething()</TD></TR></TABLE>>;fillcolor="white";shape="none";style="filled";penwidth="1";fontname="Courier New";]
        "Wap" [label=<<TABLE CELLBORDER="1" BORDER="0" CELLSPACING="0"><TR><TD bgcolor="black" align="center"><font color="white"><B>Wap</B></font></TD></TR><TR><TD PORT="Row_prop3" ALIGN="LEFT">+ [String] $prop3</TD></TR><TR><TD PORT="Row_Separator_Constructors" ALIGN="LEFT">-----Constructors-----</TD></TR><TR><TD PORT="Row_Separator_Methods" ALIGN="LEFT">-----Methods-----</TD></TR><TR><TD PORT="Row_DoChildthing" ALIGN="LEFT">+ DoChildthing()</TD></TR></TABLE>>;fillcolor="white";shape="none";style="filled";penwidth="1";fontname="Courier New";]
        "Wep" [label=<<TABLE CELLBORDER="1" BORDER="0" CELLSPACING="0"><TR><TD bgcolor="black" align="center"><font color="white"><B>Wep</B></font></TD></TR><TR><TD PORT="Row_prop4" ALIGN="LEFT">+ [String] $prop4</TD></TR><TR><TD PORT="Row_Separator_Constructors" ALIGN="LEFT">-----Constructors-----</TD></TR><TR><TD PORT="Row_Separator_Methods" ALIGN="LEFT">-----Methods-----</TD></TR><TR><TD PORT="Row_DoOtherChildThing" ALIGN="LEFT">+ DoOtherChildThing()</TD></TR></TABLE>>;fillcolor="white";shape="none";style="filled";penwidth="1";fontname="Courier New";]
    }

    "Woop"->"Wap" [arrowhead="empty";]
    "Woop"->"Wep" [arrowhead="empty";]
}

Image

image

Reproduction of the problem

This is how you can reproduce the example:

Download PsClassUtils Install-Module PsClassUtils

Change line 174 of Out-CUPasGraph (located $ModulesFolder\PSClassUtils\Functions\Private\Out-CUPSGraph.ps1)

from

edge -From $Child -To $Parent

to

edge -From $Child -To $Parent -Attributes @{arrowhead = "empty"}

or

edge -From $Child -To $Parent -LiteralAttribute "[arrowhead="empty";]" 

open ps prompt as admin, and type the following:

Write-CUClassDiagram -Path $ClassWithInheritance -Show -Passthru

(-Passthru will output the Graphviz code generated) If you need a ps1 file with inheritance, check in the example folder: $ModulesFolder\PSClassUtils\Examples\02\Inheritance.ps1

Don't hesitate to shoot me a message on slack, if you want me to test something.

Santé!

Stéphane

Stephanevg commented 5 years ago

Actually, I got this one fixed. The issue was on my side, and the attribute was perfectly set.