diff --git a/src/CalcViewModel/StandardCalculatorViewModel.cpp b/src/CalcViewModel/StandardCalculatorViewModel.cpp index 0839a9f2..ef440992 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.cpp +++ b/src/CalcViewModel/StandardCalculatorViewModel.cpp @@ -1792,7 +1792,10 @@ CalculatorApp::ViewModel::Snapshot::StandardCalculatorSnapshot ^ StandardCalcula auto result = ref new CalculatorApp::ViewModel::Snapshot::StandardCalculatorSnapshot(); result->CalcManager = ref new CalculatorApp::ViewModel::Snapshot::CalcManagerSnapshot(m_standardCalculatorManager); result->PrimaryDisplay = ref new CalculatorApp::ViewModel::Snapshot::PrimaryDisplaySnapshot(m_DisplayValue, m_IsInError); - result->ExpressionDisplay = ref new CalculatorApp::ViewModel::Snapshot::ExpressionDisplaySnapshot(*m_tokens, *m_commands); + if (!m_tokens->empty() && !m_commands->empty()) + { + result->ExpressionDisplay = ref new CalculatorApp::ViewModel::Snapshot::ExpressionDisplaySnapshot(*m_tokens, *m_commands); + } result->DisplayCommands = ref new Platform::Collections::Vector(); for (auto cmd : m_standardCalculatorManager.GetDisplayCommandsSnapshot()) { diff --git a/src/Calculator/Utils/JsonUtils.cs b/src/Calculator/Utils/JsonUtils.cs index 39ffcf18..7cfa03be 100644 --- a/src/Calculator/Utils/JsonUtils.cs +++ b/src/Calculator/Utils/JsonUtils.cs @@ -162,7 +162,7 @@ namespace CalculatorApp.JsonUtils [JsonPropertyName("h")] public IEnumerable HistoryItems // optional { - get => Value?.HistoryItems.Select(x => new CalcManagerHistoryItemAlias { Value = x }); + get => Value.HistoryItems?.Select(x => new CalcManagerHistoryItemAlias { Value = x }); set => Value.HistoryItems = value?.Select(x => new CalcManagerHistoryItem { Tokens = x.Tokens.Select(Helpers.MapHistoryToken).ToList(), @@ -240,7 +240,7 @@ namespace CalculatorApp.JsonUtils [JsonPropertyName("e")] public ExpressionDisplaySnapshotAlias ExpressionDisplay // optional { - get => Value != null ? new ExpressionDisplaySnapshotAlias(Value.ExpressionDisplay) : null; + get => Value.ExpressionDisplay != null ? new ExpressionDisplaySnapshotAlias(Value.ExpressionDisplay) : null; set => Value.ExpressionDisplay = value?.Value; } [JsonPropertyName("c")] @@ -264,7 +264,7 @@ namespace CalculatorApp.JsonUtils [JsonPropertyName("s")] public StandardCalculatorSnapshotAlias StandardCalculatorSnapshot // optional { - get => Value != null ? new StandardCalculatorSnapshotAlias(Value.StandardCalculator) : null; + get => Value.StandardCalculator != null ? new StandardCalculatorSnapshotAlias(Value.StandardCalculator) : null; set => Value.StandardCalculator = value?.Value; }