From 283001258f582b83dafd7c06ad7cd70be7a15e09 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Wed, 23 Aug 2023 08:10:47 +0200 Subject: [PATCH] Null checks --- Influx/AllaganTools/Inventory.cs | 5 +++-- Influx/SubmarineTracker/SubmarineStats.cs | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Influx/AllaganTools/Inventory.cs b/Influx/AllaganTools/Inventory.cs index 3a4ff80..449e353 100644 --- a/Influx/AllaganTools/Inventory.cs +++ b/Influx/AllaganTools/Inventory.cs @@ -23,7 +23,8 @@ internal sealed class Inventory public IEnumerable GetAllItems() => ((IEnumerable)_getAllInventories.Invoke(_delegate, Array.Empty())!) .Cast() - .SelectMany(x => x.Cast()) - .Select(x => new InventoryItem(x)) + .SelectMany(x => x.Cast()) + .Where(x => x != null) + .Select(x => new InventoryItem(x!)) .ToList(); } diff --git a/Influx/SubmarineTracker/SubmarineStats.cs b/Influx/SubmarineTracker/SubmarineStats.cs index 36186c6..9230e6c 100644 --- a/Influx/SubmarineTracker/SubmarineStats.cs +++ b/Influx/SubmarineTracker/SubmarineStats.cs @@ -1,8 +1,8 @@ namespace Influx.SubmarineTracker; -public class SubmarineStats +public sealed class SubmarineStats { - public string Name { get; init; } - public int Id { get; init; } - public ushort Level { get; init; } + public required string Name { get; init; } + public required int Id { get; init; } + public required ushort Level { get; init; } }