summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.AssemblyRewriters/Finders/MethodFinder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI.AssemblyRewriters/Finders/MethodFinder.cs')
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Finders/MethodFinder.cs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/StardewModdingAPI.AssemblyRewriters/Finders/MethodFinder.cs b/src/StardewModdingAPI.AssemblyRewriters/Finders/MethodFinder.cs
index 6c210d68..bea549ee 100644
--- a/src/StardewModdingAPI.AssemblyRewriters/Finders/MethodFinder.cs
+++ b/src/StardewModdingAPI.AssemblyRewriters/Finders/MethodFinder.cs
@@ -1,11 +1,10 @@
using Mono.Cecil;
using Mono.Cecil.Cil;
-using StardewModdingAPI.AssemblyRewriters.Framework;
namespace StardewModdingAPI.AssemblyRewriters.Finders
{
/// <summary>Finds CIL instructions that reference a given method.</summary>
- public sealed class MethodFinder : BaseMethodFinder
+ public class MethodFinder : IInstructionFinder
{
/*********
** Properties
@@ -21,7 +20,7 @@ namespace StardewModdingAPI.AssemblyRewriters.Finders
** Accessors
*********/
/// <summary>A brief noun phrase indicating what the instruction finder matches.</summary>
- public override string NounPhrase { get; }
+ public string NounPhrase { get; }
/*********
@@ -41,13 +40,15 @@ namespace StardewModdingAPI.AssemblyRewriters.Finders
/*********
** Protected methods
*********/
- /// <summary>Get whether a method reference should be rewritten.</summary>
+ /// <summary>Get whether a CIL instruction matches.</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)
+ public bool IsMatch(Instruction instruction, bool platformChanged)
{
- return methodRef.DeclaringType.FullName == this.FullTypeName
+ MethodReference methodRef = RewriteHelper.AsMethodReference(instruction);
+ return
+ methodRef != null
+ && methodRef.DeclaringType.FullName == this.FullTypeName
&& methodRef.Name == this.MethodName;
}
}