From cc1acfd734fd2d539254a1d511b20a00af98539c Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 23 Dec 2024 21:51:18 +1100 Subject: [PATCH] use EnumPolyfill.GetNames correctly (#4413) --- .../MSTest.TestAdapter/MSTestSettings.cs | 32 ++++--------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/src/Adapter/MSTest.TestAdapter/MSTestSettings.cs b/src/Adapter/MSTest.TestAdapter/MSTestSettings.cs index b773252ee3..ac899af772 100644 --- a/src/Adapter/MSTest.TestAdapter/MSTestSettings.cs +++ b/src/Adapter/MSTest.TestAdapter/MSTestSettings.cs @@ -503,11 +503,7 @@ private static MSTestSettings ToSettings(XmlReader reader, IMessageLogger? logge CultureInfo.CurrentCulture, Resource.InvalidClassCleanupLifecycleValue, value, -#if NET - string.Join(", ", Enum.GetNames()))); -#else string.Join(", ", EnumPolyfill.GetNames()))); -#endif break; } @@ -834,11 +830,7 @@ private static void SetParallelSettings(XmlReader reader, MSTestSettings setting CultureInfo.CurrentCulture, Resource.InvalidParallelScopeValue, value, -#if NET - string.Join(", ", Enum.GetNames()))); -#else string.Join(", ", EnumPolyfill.GetNames()))); -#endif break; } @@ -987,22 +979,16 @@ internal static void SetSettingsFromConfig(IConfiguration configuration, IMessag if (configuration["mstest:classCleanupLifecycle"] is string classCleanupLifecycle) { - if (TryParseEnum(classCleanupLifecycle, out ClassCleanupBehavior lifecycle)) - { - settings.ClassCleanupLifecycle = lifecycle; - } - else + if (!TryParseEnum(classCleanupLifecycle, out ClassCleanupBehavior lifecycle)) { throw new AdapterSettingsException(string.Format( CultureInfo.CurrentCulture, Resource.InvalidClassCleanupLifecycleValue, classCleanupLifecycle, -#if NET - string.Join(", ", Enum.GetNames()))); -#else string.Join(", ", EnumPolyfill.GetNames()))); -#endif } + + settings.ClassCleanupLifecycle = lifecycle; } if (configuration["mstest:parallelism:workers"] is string workers) @@ -1026,22 +1012,16 @@ internal static void SetSettingsFromConfig(IConfiguration configuration, IMessag { value = value.Equals("class", StringComparison.OrdinalIgnoreCase) ? "ClassLevel" : value.Equals("methood", StringComparison.OrdinalIgnoreCase) ? "MethodLevel" : value; - if (TryParseEnum(value, out ExecutionScope scope)) - { - settings.ParallelizationScope = scope; - } - else + if (!TryParseEnum(value, out ExecutionScope scope)) { throw new AdapterSettingsException(string.Format( CultureInfo.CurrentCulture, Resource.InvalidParallelScopeValue, value, -#if NET - string.Join(", ", Enum.GetNames()))); -#else string.Join(", ", EnumPolyfill.GetNames()))); -#endif } + + settings.ParallelizationScope = scope; } MSTestSettingsProvider.Load(configuration);