Compatibility fix

This commit is contained in:
yangzhi 2023-07-11 20:32:40 +08:00
parent a5a10e60cb
commit 24a0af3d58
2 changed files with 7 additions and 0 deletions

View File

@ -4,6 +4,12 @@ namespace StardewModdingAPI.Framework.ModLoading.RewriteFacades;
public static class EnumMethods
{
public static string[] GetNames<TEnum>() where TEnum : struct, Enum
{
Type enumType = typeof(TEnum);
return Enum.GetNames(enumType);
}
public static bool IsDefined<TEnum>(TEnum value) where TEnum : struct, Enum
{
Type enumType = typeof(TEnum);

View File

@ -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));