summaryrefslogtreecommitdiff
path: root/src/SMAPI.Internal.Patching
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Internal.Patching')
-rw-r--r--src/SMAPI.Internal.Patching/BasePatcher.cs6
-rw-r--r--src/SMAPI.Internal.Patching/HarmonyPatcher.cs2
-rw-r--r--src/SMAPI.Internal.Patching/IPatcher.cs2
-rw-r--r--src/SMAPI.Internal.Patching/PatchHelper.cs8
4 files changed, 5 insertions, 13 deletions
diff --git a/src/SMAPI.Internal.Patching/BasePatcher.cs b/src/SMAPI.Internal.Patching/BasePatcher.cs
index 6d019b52..c1936ccc 100644
--- a/src/SMAPI.Internal.Patching/BasePatcher.cs
+++ b/src/SMAPI.Internal.Patching/BasePatcher.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Reflection;
using HarmonyLib;
@@ -32,7 +30,7 @@ namespace StardewModdingAPI.Internal.Patching
/// <param name="name">The method name.</param>
/// <param name="parameters">The method parameter types, or <c>null</c> if it's not overloaded.</param>
/// <param name="generics">The method generic types, or <c>null</c> if it's not generic.</param>
- protected MethodInfo RequireMethod<TTarget>(string name, Type[] parameters = null, Type[] generics = null)
+ protected MethodInfo RequireMethod<TTarget>(string name, Type[]? parameters = null, Type[]? generics = null)
{
return PatchHelper.RequireMethod<TTarget>(name, parameters, generics);
}
@@ -42,7 +40,7 @@ namespace StardewModdingAPI.Internal.Patching
/// <param name="priority">The patch priority to apply, usually specified using Harmony's <see cref="Priority"/> enum, or <c>null</c> to keep the default value.</param>
protected HarmonyMethod GetHarmonyMethod(string name, int? priority = null)
{
- var method = new HarmonyMethod(
+ HarmonyMethod method = new(
AccessTools.Method(this.GetType(), name)
?? throw new InvalidOperationException($"Can't find patcher method {PatchHelper.GetMethodString(this.GetType(), name)}.")
);
diff --git a/src/SMAPI.Internal.Patching/HarmonyPatcher.cs b/src/SMAPI.Internal.Patching/HarmonyPatcher.cs
index fc239fd2..6f30c241 100644
--- a/src/SMAPI.Internal.Patching/HarmonyPatcher.cs
+++ b/src/SMAPI.Internal.Patching/HarmonyPatcher.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using HarmonyLib;
diff --git a/src/SMAPI.Internal.Patching/IPatcher.cs b/src/SMAPI.Internal.Patching/IPatcher.cs
index 5b373117..a732d64f 100644
--- a/src/SMAPI.Internal.Patching/IPatcher.cs
+++ b/src/SMAPI.Internal.Patching/IPatcher.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using HarmonyLib;
namespace StardewModdingAPI.Internal.Patching
diff --git a/src/SMAPI.Internal.Patching/PatchHelper.cs b/src/SMAPI.Internal.Patching/PatchHelper.cs
index 52b15fd1..edd8ef57 100644
--- a/src/SMAPI.Internal.Patching/PatchHelper.cs
+++ b/src/SMAPI.Internal.Patching/PatchHelper.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Linq;
using System.Reflection;
@@ -18,7 +16,7 @@ namespace StardewModdingAPI.Internal.Patching
/// <typeparam name="TTarget">The type containing the method.</typeparam>
/// <param name="parameters">The method parameter types, or <c>null</c> if it's not overloaded.</param>
/// <exception cref="InvalidOperationException">The type has no matching constructor.</exception>
- public static ConstructorInfo RequireConstructor<TTarget>(Type[] parameters = null)
+ public static ConstructorInfo RequireConstructor<TTarget>(Type[]? parameters = null)
{
return
AccessTools.Constructor(typeof(TTarget), parameters)
@@ -31,7 +29,7 @@ namespace StardewModdingAPI.Internal.Patching
/// <param name="parameters">The method parameter types, or <c>null</c> if it's not overloaded.</param>
/// <param name="generics">The method generic types, or <c>null</c> if it's not generic.</param>
/// <exception cref="InvalidOperationException">The type has no matching method.</exception>
- public static MethodInfo RequireMethod<TTarget>(string name, Type[] parameters = null, Type[] generics = null)
+ public static MethodInfo RequireMethod<TTarget>(string name, Type[]? parameters = null, Type[]? generics = null)
{
return
AccessTools.Method(typeof(TTarget), name, parameters, generics)
@@ -43,7 +41,7 @@ namespace StardewModdingAPI.Internal.Patching
/// <param name="name">The method name, or <c>null</c> for a constructor.</param>
/// <param name="parameters">The method parameter types, or <c>null</c> if it's not overloaded.</param>
/// <param name="generics">The method generic types, or <c>null</c> if it's not generic.</param>
- public static string GetMethodString(Type type, string name, Type[] parameters = null, Type[] generics = null)
+ public static string GetMethodString(Type type, string? name, Type[]? parameters = null, Type[]? generics = null)
{
StringBuilder str = new();