Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use EnumPolyfill.GetNames correctly #4413

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -991,22 +983,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 @@ -1030,22 +1016,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
Loading