LxLeChat / FlowChartCore

PowerShell Module Written in C# to create DOT graphs from PS Scripts
MIT License
18 stars 3 forks source link

New-FLowChartGraph throw Object reference not set to an instance of an object. #17

Closed LaurentDardenne closed 3 years ago

LaurentDardenne commented 4 years ago

The following code based on a test of the switch statement raises an exception :

$sb={
    $grade = 92
    Switch ($Grade)
    {
        {$grade -ge 90} { "Grade A";Break}
        {$grade -ge 80} { "Grade B";Break}
        {$grade -ge 70} { "Grade C";Break}
        {$grade -ge 60} { "Grade D";Break}
        default { "Grade F" }
    }
}
$Result=Find-FLowChartNodes -ScriptBlock $Sb
New-FLowChartGraph  $Result > c:\temp\testIfWithSwitch.graph # <--------- BUG
C:\Tools\Graphviz\bin\dot -Tpng c:\temp\testIfWithSwitch.graph -o c:\temp\testIfWithSwitch.png
ii c:\temp\testIfWithSwitch.png

$stacktrace:


   at FlowChartCore.Graph.BreakBuilder.CreateSpecialEdge() in C:\Users\Laurent\Downloads\FlowChartCore\FlowChartCore-master\Code\Library\GraphBuilder\BreakBuilder.cs:line 59
   at FlowChartCore.Graph.BreakBuilder..ctor(BreakNode breaknode) in C:\Users\Laurent\Downloads\FlowChartCore\FlowChartCore-master\Code\Library\GraphBuilder\BreakBuilder.cs:line 22
   at FlowChartCore.BreakNode.GenerateGraph(Boolean recursive) in C:\Users\Laurent\Downloads\FlowChartCore\FlowChartCore-master\Code\Library\Nodes - Keywords\BreakNode.cs:line 41
   at FlowChartCore.SwitchCaseNode.GenerateGraph(Boolean recursive) in C:\Users\Laurent\Downloads\FlowChartCore\FlowChartCore-master\Code\Library\Nodes - Switch\SwitchCaseNode.cs:line 78
   at FlowChartCore.SwitchNode.GenerateGraph(Boolean recursive) in C:\Users\Laurent\Downloads\FlowChartCore\FlowChartCore-master\Code\Library\Nodes - Switch\SwitchNode.cs:line 66
   at FlowChartCore.Cmdlets.NewFlowChartGraph.ProcessRecord() in C:\Users\Laurent\Downloads\FlowChartCore\FlowChartCore-master\Code\Cmdlets\NewNodeGraph.cs:line 46
   at System.Management.Automation.CommandProcessor.ProcessRecord()