diff --git a/osu.Game.Rulesets.Karaoke.Tests/Utils/EnumUtilsTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Utils/EnumUtilsTest.cs index fe5578d77..8d201806e 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Utils/EnumUtilsTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Utils/EnumUtilsTest.cs @@ -10,19 +10,6 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Utils [TestFixture] public class EnumUtilsTest { - [Test] - public void TestGetValues() - { - var expected = new[] - { - TestEnum.Enum1, - TestEnum.Enum2, - TestEnum.Enum3 - }; - var actual = EnumUtils.GetValues(); - Assert.AreEqual(expected, actual); - } - [TestCase(TestEnum.Enum1, TestEnum.Enum3)] [TestCase(TestEnum.Enum2, TestEnum.Enum1)] [TestCase(TestEnum.Enum3, TestEnum.Enum2)] diff --git a/osu.Game.Rulesets.Karaoke/Utils/EnumUtils.cs b/osu.Game.Rulesets.Karaoke/Utils/EnumUtils.cs index 88cb50959..374ef1b1f 100644 --- a/osu.Game.Rulesets.Karaoke/Utils/EnumUtils.cs +++ b/osu.Game.Rulesets.Karaoke/Utils/EnumUtils.cs @@ -9,14 +9,11 @@ namespace osu.Game.Rulesets.Karaoke.Utils { public static class EnumUtils { - public static T[] GetValues() where T : Enum - => (T[])Enum.GetValues(typeof(T)); + public static T GetPreviousValue(T v) where T : struct, Enum + => Enum.GetValues().Concat(new[] { default(T)! }).Reverse().SkipWhile(e => !EqualityComparer.Default.Equals(v, e)).Skip(1).First(); - public static T GetPreviousValue(T v) where T : Enum - => GetValues().Concat(new[] { default(T)! }).Reverse().SkipWhile(e => !EqualityComparer.Default.Equals(v, e)).Skip(1).First(); - - public static T GetNextValue(T v) where T : Enum - => GetValues().Concat(new[] { default(T)! }).SkipWhile(e => !EqualityComparer.Default.Equals(v, e)).Skip(1).First(); + public static T GetNextValue(T v) where T : struct, Enum + => Enum.GetValues().Concat(new[] { default(T)! }).SkipWhile(e => !EqualityComparer.Default.Equals(v, e)).Skip(1).First(); public static T Casting(Enum mode) => (T)(object)mode;