diff --git a/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.cs b/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.cs index 56fa01c467..3449c90813 100644 --- a/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.cs +++ b/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.cs @@ -225,12 +225,24 @@ private static async Task ValidateOptionsArgumentsAsync( } private static async Task ValidateConfigurationAsync( - IEnumerable extensionsProviders, - IEnumerable systemProviders, + Dictionary>.KeyCollection extensionsProviders, + Dictionary>.KeyCollection systemProviders, ICommandLineOptions commandLineOptions) { - StringBuilder? stringBuilder = null; - foreach (ICommandLineOptionsProvider commandLineOptionsProvider in systemProviders.Union(extensionsProviders)) + StringBuilder? stringBuilder = await ValidateConfigurationAsync(systemProviders, commandLineOptions, null); + stringBuilder = await ValidateConfigurationAsync(extensionsProviders, commandLineOptions, stringBuilder); + + return stringBuilder?.Length > 0 + ? ValidationResult.Invalid(stringBuilder.ToTrimmedString()) + : ValidationResult.Valid(); + } + + private static async Task ValidateConfigurationAsync( + Dictionary>.KeyCollection providers, + ICommandLineOptions commandLineOptions, + StringBuilder? stringBuilder) + { + foreach (ICommandLineOptionsProvider commandLineOptionsProvider in providers) { ValidationResult result = await commandLineOptionsProvider.ValidateCommandLineOptionsAsync(commandLineOptions); if (!result.IsValid) @@ -241,9 +253,7 @@ private static async Task ValidateConfigurationAsync( } } - return stringBuilder?.Length > 0 - ? ValidationResult.Invalid(stringBuilder.ToTrimmedString()) - : ValidationResult.Valid(); + return stringBuilder; } private static string ToTrimmedString(this StringBuilder stringBuilder)