Skip to content

Commit dcd535a

Browse files
committed
Insert null check
1 parent 1d847a3 commit dcd535a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Source/Monitorian.Core/Models/Monitor/DisplayMonitorProvider.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ public static async Task<DisplayItem[]> GetDisplayMonitorsAsync()
115115
{
116116
foreach (var device in devices)
117117
{
118-
if (!device.Properties.TryGetValue(deviceInstanceIdKey, out object value))
118+
// Null check is inserted because NullReferenceException is observed in this method.
119+
if ((device is null) || !device.Properties.TryGetValue(deviceInstanceIdKey, out object value))
119120
continue;
120121

121122
var deviceInstanceId = value as string;

0 commit comments

Comments
 (0)