summaryrefslogtreecommitdiff
path: root/src/SMAPI.Mods.ErrorHandler/Patches
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-13 22:06:07 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-13 22:06:07 -0400
commit2765e3f9b379f0dc2a5732c1ca9ba23dbe2a7f15 (patch)
tree3b97dd4aa6e9b7971dafa139c64a39c31e841fe6 /src/SMAPI.Mods.ErrorHandler/Patches
parentaa7b0caf4656d65ee156c3cf5ea786f561b850bb (diff)
downloadSMAPI-2765e3f9b379f0dc2a5732c1ca9ba23dbe2a7f15.tar.gz
SMAPI-2765e3f9b379f0dc2a5732c1ca9ba23dbe2a7f15.tar.bz2
SMAPI-2765e3f9b379f0dc2a5732c1ca9ba23dbe2a7f15.zip
enable nullable annotations in bundled mods (#837)
Diffstat (limited to 'src/SMAPI.Mods.ErrorHandler/Patches')
-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
9 files changed, 19 insertions, 38 deletions
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)