using System.Diagnostics.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using StardewModdingAPI.AssemblyRewriters.Framework;
namespace StardewModdingAPI.AssemblyRewriters.Finders
{
/// Finds CIL instructions that reference the former StardewModdingAPI.Extensions class, which was removed in SMAPI 1.9.
[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
*********/
/// A brief noun phrase indicating what the instruction finder matches.
public override string NounPhrase { get; } = "obsolete StardewModdingAPI.Extensions API";
/*********
** Protected methods
*********/
/// Get whether a method reference should be rewritten.
/// The IL instruction.
/// The method reference.
/// Whether the mod was compiled on a different platform.
protected override bool IsMatch(Instruction instruction, MethodReference methodRef, bool platformChanged)
{
return methodRef.DeclaringType.FullName == "StardewModdingAPI.Extensions";
}
}
}