diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-03-25 15:17:26 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-03-25 15:17:26 -0400 |
commit | 7b641d816466fe7d9229374c175f59ee32b8dc5c (patch) | |
tree | 6ed0c1036071b1eba0ca181a2c9257fbfeeedde8 /src/StardewModdingAPI.AssemblyRewriters/Finders/MethodFinder.cs | |
parent | 267e2469da290cbdb93bd58cea0272de403bbdab (diff) | |
download | SMAPI-7b641d816466fe7d9229374c175f59ee32b8dc5c.tar.gz SMAPI-7b641d816466fe7d9229374c175f59ee32b8dc5c.tar.bz2 SMAPI-7b641d816466fe7d9229374c175f59ee32b8dc5c.zip |
simplify CIL rewriter hierarchy
Diffstat (limited to 'src/StardewModdingAPI.AssemblyRewriters/Finders/MethodFinder.cs')
-rw-r--r-- | src/StardewModdingAPI.AssemblyRewriters/Finders/MethodFinder.cs | 15 |
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; } } |