From f04f70495f2f5efa222d1639420ecd48774373ab Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 18 Oct 2024 10:43:53 -0500 Subject: [PATCH] fix: check for nulls in route switch descriptors --- .../Routing/RouteSwitchDescriptor.cs | 4 ++-- .../Routing/RoutingFeedbackManager.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PepperDash.Essentials.Core/Routing/RouteSwitchDescriptor.cs b/src/PepperDash.Essentials.Core/Routing/RouteSwitchDescriptor.cs index 080b932e..9e4aaca1 100644 --- a/src/PepperDash.Essentials.Core/Routing/RouteSwitchDescriptor.cs +++ b/src/PepperDash.Essentials.Core/Routing/RouteSwitchDescriptor.cs @@ -23,9 +23,9 @@ public override string ToString() { if (SwitchingDevice is IRouting) - return $"{SwitchingDevice?.Key} switches output {OutputPort.Key} to input {InputPort.Key}"; + return $"{SwitchingDevice?.Key} switches output {OutputPort?.Key} to input {InputPort?.Key}"; else - return $"{SwitchingDevice.Key} switches to input {InputPort.Key}"; + return $"{SwitchingDevice?.Key} switches to input {InputPort?.Key}"; } } diff --git a/src/PepperDash.Essentials.Core/Routing/RoutingFeedbackManager.cs b/src/PepperDash.Essentials.Core/Routing/RoutingFeedbackManager.cs index 28fefa96..e8809191 100644 --- a/src/PepperDash.Essentials.Core/Routing/RoutingFeedbackManager.cs +++ b/src/PepperDash.Essentials.Core/Routing/RoutingFeedbackManager.cs @@ -217,7 +217,7 @@ namespace PepperDash.Essentials.Core.Routing var currentRoute = midpoint.CurrentRoutes.FirstOrDefault(route => { Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Checking {route} against {tieLine}", this, route, tieLine); - return route.OutputPort.Key == tieLine.SourcePort.Key && route.OutputPort.ParentDevice.Key == tieLine.SourcePort.ParentDevice.Key; + return route.OutputPort?.Key == tieLine.SourcePort.Key && route.OutputPort?.ParentDevice.Key == tieLine.SourcePort.ParentDevice.Key; }); if (currentRoute == null)