summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Finders/SMAPI_Extensions_MethodFinder.cs31
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj1
-rw-r--r--src/StardewModdingAPI/Constants.cs3
3 files changed, 35 insertions, 0 deletions
diff --git a/src/StardewModdingAPI.AssemblyRewriters/Finders/SMAPI_Extensions_MethodFinder.cs b/src/StardewModdingAPI.AssemblyRewriters/Finders/SMAPI_Extensions_MethodFinder.cs
new file mode 100644
index 00000000..f359b595
--- /dev/null
+++ b/src/StardewModdingAPI.AssemblyRewriters/Finders/SMAPI_Extensions_MethodFinder.cs
@@ -0,0 +1,31 @@
+using System.Diagnostics.CodeAnalysis;
+using Mono.Cecil;
+using Mono.Cecil.Cil;
+using StardewModdingAPI.AssemblyRewriters.Framework;
+
+namespace StardewModdingAPI.AssemblyRewriters.Finders
+{
+ /// <summary>Matches CIL instructions that reference the former <c>StardewModdingAPI.Extensions</c> class, which was removed in SMAPI 1.9.</summary>
+ [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "This class is not meant to be used directly, and is deliberately named to make it easier to know what it changes at a glance.")]
+ public class SMAPI_Extensions_MethodFinder : BaseMethodFinder
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>A brief noun phrase indicating what the instruction finder matches.</summary>
+ public override string NounPhrase { get; } = "obsolete StardewModdingAPI.Extensions API";
+
+
+ /*********
+ ** Protected methods
+ *********/
+ /// <summary>Get whether a method reference should be rewritten.</summary>
+ /// <param name="instruction">The IL instruction.</param>
+ /// <param name="methodRef">The method reference.</param>
+ /// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
+ protected override bool IsMatch(Instruction instruction, MethodReference methodRef, bool platformChanged)
+ {
+ return methodRef.DeclaringType.FullName == "StardewModdingAPI.Extensions";
+ }
+ }
+}
diff --git a/src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj b/src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj
index 03ed6f3a..4d96d5d3 100644
--- a/src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj
+++ b/src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj
@@ -66,6 +66,7 @@
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
+ <Compile Include="Finders\SMAPI_Extensions_MethodFinder.cs" />
<Compile Include="Framework\BaseFieldFinder.cs" />
<Compile Include="Framework\BaseMethodFinder.cs" />
<Compile Include="IInstructionRewriter.cs" />
diff --git a/src/StardewModdingAPI/Constants.cs b/src/StardewModdingAPI/Constants.cs
index d8149766..f18e0792 100644
--- a/src/StardewModdingAPI/Constants.cs
+++ b/src/StardewModdingAPI/Constants.cs
@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Reflection;
using StardewModdingAPI.AssemblyRewriters;
+using StardewModdingAPI.AssemblyRewriters.Finders;
using StardewModdingAPI.AssemblyRewriters.Rewriters.Crossplatform;
using StardewModdingAPI.AssemblyRewriters.Rewriters.SDV1_2;
using StardewValley;
@@ -140,6 +141,8 @@ namespace StardewModdingAPI
{
return new IInstructionFinder[]
{
+ // APIs removed in SMAPI 1.9
+ new SMAPI_Extensions_MethodFinder()
};
}