summaryrefslogtreecommitdiff
path: root/src/SMAPI.Mods.ErrorHandler
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Mods.ErrorHandler')
-rw-r--r--src/SMAPI.Mods.ErrorHandler/ModEntry.cs6
-rw-r--r--src/SMAPI.Mods.ErrorHandler/Patches/DialoguePatcher.cs10
-rw-r--r--src/SMAPI.Mods.ErrorHandler/Patches/EventPatcher.cs4
-rw-r--r--src/SMAPI.Mods.ErrorHandler/Patches/GameLocationPatcher.cs9
-rw-r--r--src/SMAPI.Mods.ErrorHandler/Patches/IClickableMenuPatcher.cs2
-rw-r--r--src/SMAPI.Mods.ErrorHandler/Patches/NpcPatcher.cs8
-rw-r--r--src/SMAPI.Mods.ErrorHandler/Patches/ObjectPatcher.cs4
-rw-r--r--src/SMAPI.Mods.ErrorHandler/Patches/SaveGamePatcher.cs10
-rw-r--r--src/SMAPI.Mods.ErrorHandler/Patches/SpriteBatchPatcher.cs6
-rw-r--r--src/SMAPI.Mods.ErrorHandler/Patches/UtilityPatcher.cs4
10 files changed, 21 insertions, 42 deletions
diff --git a/src/SMAPI.Mods.ErrorHandler/ModEntry.cs b/src/SMAPI.Mods.ErrorHandler/ModEntry.cs
index fa171012..bfbfd2dc 100644
--- a/src/SMAPI.Mods.ErrorHandler/ModEntry.cs
+++ b/src/SMAPI.Mods.ErrorHandler/ModEntry.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Reflection;
using StardewModdingAPI.Events;
@@ -59,7 +57,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler
/// <summary>The method invoked when a save is loaded.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
- private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
+ private void OnSaveLoaded(object? sender, SaveLoadedEventArgs e)
{
// show in-game warning for removed save content
if (this.IsSaveContentRemoved)
@@ -82,7 +80,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler
MethodInfo getMonitorForGame = coreType.GetMethod("GetMonitorForGame")
?? throw new InvalidOperationException("Can't access the SMAPI's 'GetMonitorForGame' method. This mod may not work correctly.");
- return (IMonitor)getMonitorForGame.Invoke(core, Array.Empty<object>()) ?? this.Monitor;
+ return (IMonitor?)getMonitorForGame.Invoke(core, Array.Empty<object>()) ?? this.Monitor;
}
}
}
diff --git a/src/SMAPI.Mods.ErrorHandler/Patches/DialoguePatcher.cs b/src/SMAPI.Mods.ErrorHandler/Patches/DialoguePatcher.cs
index b05c8cca..e98eec3c 100644
--- a/src/SMAPI.Mods.ErrorHandler/Patches/DialoguePatcher.cs
+++ b/src/SMAPI.Mods.ErrorHandler/Patches/DialoguePatcher.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Diagnostics.CodeAnalysis;
using HarmonyLib;
@@ -19,10 +17,10 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
** Fields
*********/
/// <summary>Writes messages to the console and log file on behalf of the game.</summary>
- private static IMonitor MonitorForGame;
+ private static IMonitor MonitorForGame = null!;
/// <summary>Simplifies access to private code.</summary>
- private static IReflectionHelper Reflection;
+ private static IReflectionHelper Reflection = null!;
/*********
@@ -56,12 +54,12 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
/// <param name="speaker">The NPC for which the dialogue is being parsed.</param>
/// <param name="__exception">The exception thrown by the wrapped method, if any.</param>
/// <returns>Returns the exception to throw, if any.</returns>
- private static Exception Finalize_Constructor(Dialogue __instance, string masterDialogue, NPC speaker, Exception __exception)
+ private static Exception? Finalize_Constructor(Dialogue __instance, string masterDialogue, NPC? speaker, Exception? __exception)
{
if (__exception != null)
{
// log message
- string name = !string.IsNullOrWhiteSpace(speaker?.Name) ? speaker.Name : null;
+ string? name = !string.IsNullOrWhiteSpace(speaker?.Name) ? speaker.Name : null;
DialoguePatcher.MonitorForGame.Log($"Failed parsing dialogue string{(name != null ? $" for {name}" : "")}:\n{masterDialogue}\n{__exception.GetLogSummary()}", LogLevel.Error);
// set default dialogue
diff --git a/src/SMAPI.Mods.ErrorHandler/Patches/EventPatcher.cs b/src/SMAPI.Mods.ErrorHandler/Patches/EventPatcher.cs
index 63674d09..073c62cc 100644
--- a/src/SMAPI.Mods.ErrorHandler/Patches/EventPatcher.cs
+++ b/src/SMAPI.Mods.ErrorHandler/Patches/EventPatcher.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Diagnostics.CodeAnalysis;
using HarmonyLib;
@@ -18,7 +16,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
** Fields
*********/
/// <summary>Writes messages to the console and log file on behalf of the game.</summary>
- private static IMonitor MonitorForGame;
+ private static IMonitor MonitorForGame = null!;
/*********
diff --git a/src/SMAPI.Mods.ErrorHandler/Patches/GameLocationPatcher.cs b/src/SMAPI.Mods.ErrorHandler/Patches/GameLocationPatcher.cs
index 98aa4a38..9247fa48 100644
--- a/src/SMAPI.Mods.ErrorHandler/Patches/GameLocationPatcher.cs
+++ b/src/SMAPI.Mods.ErrorHandler/Patches/GameLocationPatcher.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Diagnostics.CodeAnalysis;
using HarmonyLib;
@@ -19,8 +17,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
** Fields
*********/
/// <summary>Writes messages to the console and log file on behalf of the game.</summary>
- private static IMonitor MonitorForGame;
-
+ private static IMonitor MonitorForGame = null!;
/*********
** Public methods
@@ -54,7 +51,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
/// <param name="precondition">The precondition to be parsed.</param>
/// <param name="__exception">The exception thrown by the wrapped method, if any.</param>
/// <returns>Returns the exception to throw, if any.</returns>
- private static Exception Finalize_CheckEventPrecondition(ref int __result, string precondition, Exception __exception)
+ private static Exception? Finalize_CheckEventPrecondition(ref int __result, string precondition, Exception? __exception)
{
if (__exception != null)
{
@@ -70,7 +67,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
/// <param name="map">The map whose tilesheets to update.</param>
/// <param name="__exception">The exception thrown by the wrapped method, if any.</param>
/// <returns>Returns the exception to throw, if any.</returns>
- private static Exception Finalize_UpdateSeasonalTileSheets(GameLocation __instance, Map map, Exception __exception)
+ private static Exception? Finalize_UpdateSeasonalTileSheets(GameLocation __instance, Map map, Exception? __exception)
{
if (__exception != null)
GameLocationPatcher.MonitorForGame.Log($"Failed updating seasonal tilesheets for location '{__instance.NameOrUniqueName}': \n{__exception}", LogLevel.Error);
diff --git a/src/SMAPI.Mods.ErrorHandler/Patches/IClickableMenuPatcher.cs b/src/SMAPI.Mods.ErrorHandler/Patches/IClickableMenuPatcher.cs
index 85ce8ac4..b65a695a 100644
--- a/src/SMAPI.Mods.ErrorHandler/Patches/IClickableMenuPatcher.cs
+++ b/src/SMAPI.Mods.ErrorHandler/Patches/IClickableMenuPatcher.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System.Diagnostics.CodeAnalysis;
using HarmonyLib;
using StardewModdingAPI.Internal.Patching;
diff --git a/src/SMAPI.Mods.ErrorHandler/Patches/NpcPatcher.cs b/src/SMAPI.Mods.ErrorHandler/Patches/NpcPatcher.cs
index 5354f724..11f7ec69 100644
--- a/src/SMAPI.Mods.ErrorHandler/Patches/NpcPatcher.cs
+++ b/src/SMAPI.Mods.ErrorHandler/Patches/NpcPatcher.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -20,7 +18,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
** Fields
*********/
/// <summary>Writes messages to the console and log file on behalf of the game.</summary>
- private static IMonitor MonitorForGame;
+ private static IMonitor MonitorForGame = null!;
/*********
@@ -56,7 +54,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
/// <param name="__result">The return value of the original method.</param>
/// <param name="__exception">The exception thrown by the wrapped method, if any.</param>
/// <returns>Returns the exception to throw, if any.</returns>
- private static Exception Finalize_CurrentDialogue(NPC __instance, ref Stack<Dialogue> __result, Exception __exception)
+ private static Exception? Finalize_CurrentDialogue(NPC __instance, ref Stack<Dialogue> __result, Exception? __exception)
{
if (__exception == null)
return null;
@@ -73,7 +71,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
/// <param name="__result">The patched method's return value.</param>
/// <param name="__exception">The exception thrown by the wrapped method, if any.</param>
/// <returns>Returns the exception to throw, if any.</returns>
- private static Exception Finalize_ParseMasterSchedule(string rawData, NPC __instance, ref Dictionary<int, SchedulePathDescription> __result, Exception __exception)
+ private static Exception? Finalize_ParseMasterSchedule(string rawData, NPC __instance, ref Dictionary<int, SchedulePathDescription> __result, Exception? __exception)
{
if (__exception != null)
{
diff --git a/src/SMAPI.Mods.ErrorHandler/Patches/ObjectPatcher.cs b/src/SMAPI.Mods.ErrorHandler/Patches/ObjectPatcher.cs
index 499718b0..09a6fbbd 100644
--- a/src/SMAPI.Mods.ErrorHandler/Patches/ObjectPatcher.cs
+++ b/src/SMAPI.Mods.ErrorHandler/Patches/ObjectPatcher.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -59,7 +57,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
/// <param name="__result">The patched method's return value.</param>
/// <param name="__exception">The exception thrown by the wrapped method, if any.</param>
/// <returns>Returns the exception to throw, if any.</returns>
- private static Exception Finalize_Object_loadDisplayName(ref string __result, Exception __exception)
+ private static Exception? Finalize_Object_loadDisplayName(ref string __result, Exception? __exception)
{
if (__exception is KeyNotFoundException)
{
diff --git a/src/SMAPI.Mods.ErrorHandler/Patches/SaveGamePatcher.cs b/src/SMAPI.Mods.ErrorHandler/Patches/SaveGamePatcher.cs
index 1941d2a8..490bbfb6 100644
--- a/src/SMAPI.Mods.ErrorHandler/Patches/SaveGamePatcher.cs
+++ b/src/SMAPI.Mods.ErrorHandler/Patches/SaveGamePatcher.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -24,10 +22,10 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
** Fields
*********/
/// <summary>Writes messages to the console and log file.</summary>
- private static IMonitor Monitor;
+ private static IMonitor Monitor = null!;
/// <summary>A callback invoked when custom content is removed from the save data to avoid a crash.</summary>
- private static Action OnContentRemoved;
+ private static Action OnContentRemoved = null!;
/*********
@@ -76,7 +74,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
/// <summary>The method to call after <see cref="SaveGame.LoadFarmType"/> throws an exception.</summary>
/// <param name="__exception">The exception thrown by the wrapped method, if any.</param>
/// <returns>Returns the exception to throw, if any.</returns>
- private static Exception Finalize_LoadFarmType(Exception __exception)
+ private static Exception? Finalize_LoadFarmType(Exception? __exception)
{
// missing custom farm type
if (__exception?.Message.Contains("not a valid farm type") == true && !int.TryParse(SaveGame.loaded.whichFarm, out _))
@@ -110,7 +108,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
/// <summary>Remove content which no longer exists in the game data.</summary>
/// <param name="location">The current game location.</param>
/// <param name="npcs">The NPC data.</param>
- private static bool RemoveBrokenContent(GameLocation location, IDictionary<string, string> npcs)
+ private static bool RemoveBrokenContent(GameLocation? location, IDictionary<string, string> npcs)
{
bool removedAny = false;
if (location == null)
diff --git a/src/SMAPI.Mods.ErrorHandler/Patches/SpriteBatchPatcher.cs b/src/SMAPI.Mods.ErrorHandler/Patches/SpriteBatchPatcher.cs
index b4c03bb9..d369e0ef 100644
--- a/src/SMAPI.Mods.ErrorHandler/Patches/SpriteBatchPatcher.cs
+++ b/src/SMAPI.Mods.ErrorHandler/Patches/SpriteBatchPatcher.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Diagnostics.CodeAnalysis;
using HarmonyLib;
@@ -30,9 +28,9 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
/*********
** Private methods
*********/
- /// <summary>The method to call after <see cref="SpriteBatch.CheckValid"/>.</summary>
+ /// <summary>The method to call after <see cref="SpriteBatch.CheckValid(Texture2D)"/>.</summary>
/// <param name="texture">The texture to validate.</param>
- private static void After_CheckValid(Texture2D texture)
+ private static void After_CheckValid(Texture2D? texture)
{
if (texture?.IsDisposed == true)
throw new ObjectDisposedException("Cannot draw this texture because it's disposed.");
diff --git a/src/SMAPI.Mods.ErrorHandler/Patches/UtilityPatcher.cs b/src/SMAPI.Mods.ErrorHandler/Patches/UtilityPatcher.cs
index 108ed585..6d75a581 100644
--- a/src/SMAPI.Mods.ErrorHandler/Patches/UtilityPatcher.cs
+++ b/src/SMAPI.Mods.ErrorHandler/Patches/UtilityPatcher.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Diagnostics.CodeAnalysis;
using HarmonyLib;
@@ -35,7 +33,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
/// <param name="delimiter">The delimiter by which to split the text description.</param>
/// <param name="__exception">The exception thrown by the wrapped method, if any.</param>
/// <returns>Returns the exception to throw, if any.</returns>
- private static Exception Finalize_GetItemFromStandardTextDescription(string description, char delimiter, ref Exception __exception)
+ private static Exception? Finalize_GetItemFromStandardTextDescription(string description, char delimiter, ref Exception? __exception)
{
return __exception != null
? new FormatException($"Failed to parse item text description \"{description}\" with delimiter \"{delimiter}\".", __exception)