From c47d93020de733f0e383c6afb0bb12c4918e0cd2 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sat, 15 Jun 2024 09:24:24 +0200 Subject: [PATCH] Fixed a snapshot mapping error --- .../DamageMeterSnapshotFragment.cs | 2 +- .../DamageMeterSnapshotFragmentDto.cs | 2 +- .../DamageMeter/SnapshotMapping.cs | 23 +++++++++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragment.cs b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragment.cs index d6bb5ddd..e5c31c9c 100644 --- a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragment.cs +++ b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragment.cs @@ -126,7 +126,7 @@ public double Hps #region Spells - public List Spells { get; init; } + public List Spells { get; init; } = new (); public Visibility SpellsContainerVisibility { diff --git a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragmentDto.cs b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragmentDto.cs index c529336c..3ed2bb30 100644 --- a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragmentDto.cs +++ b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragmentDto.cs @@ -33,7 +33,7 @@ public sealed class DamageMeterSnapshotFragmentDto #region Spells - public List Spells { get; set; } + public List Spells { get; set; } = new (); #endregion diff --git a/src/StatisticsAnalysisTool/DamageMeter/SnapshotMapping.cs b/src/StatisticsAnalysisTool/DamageMeter/SnapshotMapping.cs index 7a028187..8c439694 100644 --- a/src/StatisticsAnalysisTool/DamageMeter/SnapshotMapping.cs +++ b/src/StatisticsAnalysisTool/DamageMeter/SnapshotMapping.cs @@ -1,5 +1,4 @@ -using StatisticsAnalysisTool.Enumerations; -using System.Linq; +using System.Linq; namespace StatisticsAnalysisTool.DamageMeter; @@ -25,6 +24,11 @@ public static DamageMeterSnapshot Mapping(DamageMeterSnapshotDto snapshotDto) private static DamageMeterSnapshotFragmentDto Mapping(DamageMeterSnapshotFragment snapshot) { + if (snapshot is null) + { + return new DamageMeterSnapshotFragmentDto(); + } + return new DamageMeterSnapshotFragmentDto() { Name = snapshot.Name, @@ -51,6 +55,11 @@ private static DamageMeterSnapshotFragmentDto Mapping(DamageMeterSnapshotFragmen private static DamageMeterSnapshotFragment Mapping(DamageMeterSnapshotFragmentDto snapshotFragmentDto) { + if (snapshotFragmentDto is null) + { + return new DamageMeterSnapshotFragment(); + } + return new DamageMeterSnapshotFragment() { Name = snapshotFragmentDto.Name, @@ -75,6 +84,11 @@ private static DamageMeterSnapshotFragment Mapping(DamageMeterSnapshotFragmentDt private static SpellFragmentDto Mapping(SpellsSnapshotFragment snapshot) { + if (snapshot is null) + { + return new SpellFragmentDto(); + } + return new SpellFragmentDto() { SpellIndex = snapshot.SpellIndex, @@ -91,6 +105,11 @@ private static SpellFragmentDto Mapping(SpellsSnapshotFragment snapshot) private static SpellsSnapshotFragment Mapping(SpellFragmentDto snapshotDto) { + if (snapshotDto is null) + { + return new SpellsSnapshotFragment(); + } + return new SpellsSnapshotFragment() { SpellIndex = snapshotDto.SpellIndex,