summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs')
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs b/src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs
index 359ca63e..9d0184c6 100644
--- a/src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs
+++ b/src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.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 event.</summary>
- public sealed class EventFinder : BaseMethodFinder
+ public sealed class EventFinder : 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 == "add_" + this.EventName || methodRef.Name == "remove_" + this.EventName);
}
}