From 24a0af3d58917bbe95c612c33c6847ceb3b2b473 Mon Sep 17 00:00:00 2001 From: yangzhi Date: Tue, 11 Jul 2023 20:32:40 +0800 Subject: [PATCH] Compatibility fix --- .../Framework/ModLoading/RewriteFacades/EnumMethods.cs | 6 ++++++ src/SMAPI/Metadata/InstructionMetadata.cs | 1 + 2 files changed, 7 insertions(+) diff --git a/src/SMAPI/Framework/ModLoading/RewriteFacades/EnumMethods.cs b/src/SMAPI/Framework/ModLoading/RewriteFacades/EnumMethods.cs index cd03229b..8ed17e6b 100644 --- a/src/SMAPI/Framework/ModLoading/RewriteFacades/EnumMethods.cs +++ b/src/SMAPI/Framework/ModLoading/RewriteFacades/EnumMethods.cs @@ -4,6 +4,12 @@ namespace StardewModdingAPI.Framework.ModLoading.RewriteFacades; public static class EnumMethods { + public static string[] GetNames() where TEnum : struct, Enum + { + Type enumType = typeof(TEnum); + return Enum.GetNames(enumType); + } + public static bool IsDefined(TEnum value) where TEnum : struct, Enum { Type enumType = typeof(TEnum); diff --git a/src/SMAPI/Metadata/InstructionMetadata.cs b/src/SMAPI/Metadata/InstructionMetadata.cs index f019868c..b2315e9d 100644 --- a/src/SMAPI/Metadata/InstructionMetadata.cs +++ b/src/SMAPI/Metadata/InstructionMetadata.cs @@ -119,6 +119,7 @@ namespace StardewModdingAPI.Metadata yield return new MethodToAnotherStaticMethodRewriter(typeof(ISoundBank), (method) => method.Name == nameof(SoundBankMethods.GetCueDefinition), typeof(SoundBankMethods), "GetCueDefinition"); yield return new MethodToAnotherStaticMethodRewriter(typeof(Enum), (method) => method.Name == nameof(EnumMethods.IsDefined) && method.Parameters.Count == 1, typeof(EnumMethods), "IsDefined"); + yield return new MethodToAnotherStaticMethodRewriter(typeof(Enum), (method) => method.Name == nameof(EnumMethods.GetNames) && method.Parameters.Count == 0, typeof(EnumMethods), "GetNames"); //Constructor Rewrites yield return new MethodParentRewriter(typeof(MapPage), typeof(MapPageMethods));