Skip to content

Commit

Permalink
use EnumPolyfill.GetNames correctly (#4413)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Dec 23, 2024
1 parent 811d014 commit cc1acfd
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions src/Adapter/MSTest.TestAdapter/MSTestSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,7 @@ private static MSTestSettings ToSettings(XmlReader reader, IMessageLogger? logge
CultureInfo.CurrentCulture,
Resource.InvalidClassCleanupLifecycleValue,
value,
#if NET
string.Join(", ", Enum.GetNames<ClassCleanupBehavior>())));
#else
string.Join(", ", EnumPolyfill.GetNames<ClassCleanupBehavior>())));
#endif

break;
}
Expand Down Expand Up @@ -834,11 +830,7 @@ private static void SetParallelSettings(XmlReader reader, MSTestSettings setting
CultureInfo.CurrentCulture,
Resource.InvalidParallelScopeValue,
value,
#if NET
string.Join(", ", Enum.GetNames<ExecutionScope>())));
#else
string.Join(", ", EnumPolyfill.GetNames<ExecutionScope>())));
#endif

break;
}
Expand Down Expand Up @@ -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<ClassCleanupBehavior>())));
#else
string.Join(", ", EnumPolyfill.GetNames<ClassCleanupBehavior>())));
#endif
}

settings.ClassCleanupLifecycle = lifecycle;
}

if (configuration["mstest:parallelism:workers"] is string workers)
Expand All @@ -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<ExecutionScope>())));
#else
string.Join(", ", EnumPolyfill.GetNames<ExecutionScope>())));
#endif
}

settings.ParallelizationScope = scope;
}

MSTestSettingsProvider.Load(configuration);
Expand Down

0 comments on commit cc1acfd

Please sign in to comment.