From 8a422e7e7f517dc7cb705b3e53e9f5010f6ed1e2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 May 2026 12:23:54 +0000 Subject: [PATCH 1/4] Initial plan From 21ccacd7a46c828f4cb34ba057f7ddb0ce177c30 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 May 2026 12:34:23 +0000 Subject: [PATCH 2/4] Include command line in validation errors Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com> --- .../CommandLineOptionsValidator.cs | 24 ++++++++++-- .../CommandLine/ParseResult.cs | 32 ++++++++++++---- .../CommandLine/Parser.cs | 3 +- .../Resources/PlatformResources.resx | 4 ++ .../Resources/xlf/PlatformResources.cs.xlf | 5 +++ .../Resources/xlf/PlatformResources.de.xlf | 5 +++ .../Resources/xlf/PlatformResources.es.xlf | 5 +++ .../Resources/xlf/PlatformResources.fr.xlf | 5 +++ .../Resources/xlf/PlatformResources.it.xlf | 5 +++ .../Resources/xlf/PlatformResources.ja.xlf | 5 +++ .../Resources/xlf/PlatformResources.ko.xlf | 5 +++ .../Resources/xlf/PlatformResources.pl.xlf | 5 +++ .../Resources/xlf/PlatformResources.pt-BR.xlf | 5 +++ .../Resources/xlf/PlatformResources.ru.xlf | 5 +++ .../Resources/xlf/PlatformResources.tr.xlf | 5 +++ .../xlf/PlatformResources.zh-Hans.xlf | 5 +++ .../xlf/PlatformResources.zh-Hant.xlf | 5 +++ .../CommandLine/ArgumentArityTests.cs | 30 ++++++++++++--- .../CommandLine/CommandLineHandlerTests.cs | 38 +++++++++++++++++-- 19 files changed, 176 insertions(+), 20 deletions(-) diff --git a/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.cs b/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.cs index 88f1a28e72..05800c0a11 100644 --- a/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.cs +++ b/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.cs @@ -25,7 +25,7 @@ public static async Task ValidateAsync( stringBuilder.AppendLine(CultureInfo.InvariantCulture, $"\t- {error}"); } - return ValidationResult.Invalid(stringBuilder.ToTrimmedString()); + return InvalidWithCommandLine(commandLineParseResult, stringBuilder.ToTrimmedString()); } var extensionOptionsByProvider = extensionCommandLineOptionsProviders.ToDictionary(p => p, p => p.GetCommandLineOptions()); @@ -47,7 +47,7 @@ public static async Task ValidateAsync( if (ValidateNoUnknownOptions(commandLineParseResult, extensionOptionsByProvider, systemOptionsByProvider) is { IsValid: false } result4) { - return result4; + return AddCommandLine(commandLineParseResult, result4); } var providerAndOptionByOptionName = extensionOptionsByProvider.Union(systemOptionsByProvider) @@ -56,12 +56,12 @@ public static async Task ValidateAsync( if (ValidateOptionsArgumentArity(commandLineParseResult, providerAndOptionByOptionName) is { IsValid: false } result5) { - return result5; + return AddCommandLine(commandLineParseResult, result5); } if (await ValidateOptionsArgumentsAsync(commandLineParseResult, providerAndOptionByOptionName).ConfigureAwait(false) is { IsValid: false } result6) { - return result6; + return AddCommandLine(commandLineParseResult, result6); } // Last validation step @@ -323,4 +323,20 @@ private static string ToTrimmedString(this StringBuilder stringBuilder) return stringBuilder.ToString(); } + + private static ValidationResult AddCommandLine(CommandLineParseResult parseResult, ValidationResult result) + => result.IsValid ? result : InvalidWithCommandLine(parseResult, result.ErrorMessage); + + private static ValidationResult InvalidWithCommandLine(CommandLineParseResult parseResult, string errorMessage) + { + if (parseResult.CommandLine.Length == 0) + { + return ValidationResult.Invalid(errorMessage); + } + + var stringBuilder = new StringBuilder(errorMessage); + stringBuilder.AppendLine(); + stringBuilder.AppendFormat(CultureInfo.InvariantCulture, PlatformResources.CommandLineValidationCommandLine, parseResult.CommandLine); + return ValidationResult.Invalid(stringBuilder.ToString()); + } } diff --git a/src/Platform/Microsoft.Testing.Platform/CommandLine/ParseResult.cs b/src/Platform/Microsoft.Testing.Platform/CommandLine/ParseResult.cs index 1a39282dc7..bb90839bc3 100644 --- a/src/Platform/Microsoft.Testing.Platform/CommandLine/ParseResult.cs +++ b/src/Platform/Microsoft.Testing.Platform/CommandLine/ParseResult.cs @@ -6,11 +6,8 @@ namespace Microsoft.Testing.Platform.CommandLine; /// /// Represents the result of parsing a command line. /// -/// The name of the tool. -/// The collection of parsed options. -/// The collection of errors associated to the parsing. [Experimental("TPEXP", UrlFormat = "https://aka.ms/testingplatform/diagnostics#{0}")] -public sealed class CommandLineParseResult(string? toolName, IReadOnlyList options, IReadOnlyList errors) : IEquatable +public sealed class CommandLineParseResult : IEquatable { /// /// The prefix for options. @@ -22,20 +19,41 @@ public sealed class CommandLineParseResult(string? toolName, IReadOnlyList public static CommandLineParseResult Empty => new(null, [], []); + /// + /// Initializes a new instance of the class. + /// + /// The name of the tool. + /// The collection of parsed options. + /// The collection of errors associated to the parsing. + public CommandLineParseResult(string? toolName, IReadOnlyList options, IReadOnlyList errors) + : this(toolName, options, errors, []) + { + } + + internal CommandLineParseResult(string? toolName, IReadOnlyList options, IReadOnlyList errors, IReadOnlyList arguments) + { + ToolName = toolName; + Options = options; + Errors = errors; + CommandLine = string.Join(" ", arguments); + } + /// /// Gets the name of the tool. /// - public string? ToolName { get; } = toolName; + public string? ToolName { get; } /// /// Gets the collection of parsed options. /// - public IReadOnlyList Options { get; } = options; + public IReadOnlyList Options { get; } /// /// Gets the collection of errors associated to the parsing. /// - public IReadOnlyList Errors { get; } = errors; + public IReadOnlyList Errors { get; } + + internal string CommandLine { get; } /// /// Gets a value indicating whether the parsing has errors. diff --git a/src/Platform/Microsoft.Testing.Platform/CommandLine/Parser.cs b/src/Platform/Microsoft.Testing.Platform/CommandLine/Parser.cs index 6ce2d0ab8d..0c520b2cfa 100644 --- a/src/Platform/Microsoft.Testing.Platform/CommandLine/Parser.cs +++ b/src/Platform/Microsoft.Testing.Platform/CommandLine/Parser.cs @@ -35,6 +35,7 @@ public static CommandLineParseResult Parse(string[] args, IEnvironment environme private static CommandLineParseResult Parse(List args, IEnvironment environment) { + string[] originalArgs = [.. args]; List options = []; List errors = []; @@ -101,7 +102,7 @@ private static CommandLineParseResult Parse(List args, IEnvironment envi options.Add(new(currentOption, [.. currentOptionArguments])); } - return new CommandLineParseResult(toolName, options, errors); + return new CommandLineParseResult(toolName, options, errors, originalArgs); static void ParseOptionAndSeparators(string arg, out string? currentOption, out string? currentArg) { diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx b/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx index 2b1b96918f..4ac874a289 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx +++ b/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx @@ -304,6 +304,10 @@ Invalid command line arguments: + + Command line: {0} + {0} is the command line used to run the application. + Invalid arity, maximum must be greater than minimum diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf index eb50d2d177..4e9ff8c87e 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf @@ -162,6 +162,11 @@ Neznámá možnost --{0} + + Command line: {0} + Command line: {0} + {0} is the command line used to run the application. + The same instance of 'CompositeExtensionFactory' is already registered Už je zaregistrovaná stejná instance CompositeExtensionFactory. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf index 95a59bc488..7157ccdd4b 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf @@ -162,6 +162,11 @@ Unbekannte Option "--{0}" + + Command line: {0} + Command line: {0} + {0} is the command line used to run the application. + The same instance of 'CompositeExtensionFactory' is already registered Die gleiche Instanz von „CompositeExtensionFactory“ ist bereits registriert diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf index 7498efda2d..5b2f3eb0ff 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf @@ -162,6 +162,11 @@ Opción desconocida “--{0}” + + Command line: {0} + Command line: {0} + {0} is the command line used to run the application. + The same instance of 'CompositeExtensionFactory' is already registered La misma instancia de "CompositeExtensionFactory" ya está registrada diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf index 84f1baa049..0902b28e5d 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf @@ -162,6 +162,11 @@ Option « --{0} » inconnue. + + Command line: {0} + Command line: {0} + {0} is the command line used to run the application. + The same instance of 'CompositeExtensionFactory' is already registered La même instance de 'CompositeExtensionFactory' est déjà enregistrée diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf index 7dcc50f3cc..270447a77e 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf @@ -162,6 +162,11 @@ Opzione sconosciuta: '--{0}' + + Command line: {0} + Command line: {0} + {0} is the command line used to run the application. + The same instance of 'CompositeExtensionFactory' is already registered L'istanza di 'CompositeExtensionFactory' specificata è già registrata diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf index fd6c736980..7e81d13825 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf @@ -162,6 +162,11 @@ 不明なオプション: '--{0}' + + Command line: {0} + Command line: {0} + {0} is the command line used to run the application. + The same instance of 'CompositeExtensionFactory' is already registered 'CompositeExtensionFactory' の同じインスタンスが既に登録されています diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf index ddbc83c020..dc065f5582 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf @@ -162,6 +162,11 @@ 알 수 없는 옵션 '--{0}' + + Command line: {0} + Command line: {0} + {0} is the command line used to run the application. + The same instance of 'CompositeExtensionFactory' is already registered 동일한 'CompositeExtensionFactory' 인스턴스가 이미 등록됨 diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf index 3f4afe566f..dd0ff2e74d 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf @@ -162,6 +162,11 @@ Nieznana opcja: „--{0}” + + Command line: {0} + Command line: {0} + {0} is the command line used to run the application. + The same instance of 'CompositeExtensionFactory' is already registered To samo wystąpienie elementu „CompositeExtensionFactory” jest już zarejestrowane diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf index 6e7cd587d1..8c68785d7a 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf @@ -162,6 +162,11 @@ Opção desconhecida '--{0}' + + Command line: {0} + Command line: {0} + {0} is the command line used to run the application. + The same instance of 'CompositeExtensionFactory' is already registered A mesma instância de 'CompositeExtensionFactory' já está registrada diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf index e6e8098163..fb8c1e7066 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf @@ -162,6 +162,11 @@ Неизвестный параметр "--{0}" + + Command line: {0} + Command line: {0} + {0} is the command line used to run the application. + The same instance of 'CompositeExtensionFactory' is already registered Такой же экземпляр "CompositeExtensonFactory" уже зарегистрирован diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf index 2a70594081..d08c861ed2 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf @@ -162,6 +162,11 @@ '--{0}' seçeneği bilinmiyor + + Command line: {0} + Command line: {0} + {0} is the command line used to run the application. + The same instance of 'CompositeExtensionFactory' is already registered Aynı 'CompositeExtensionFactory' örneği zaten kayıtlı diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf index 51121cef90..f2646aa6b1 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf @@ -162,6 +162,11 @@ 未知选项:“--{0}” + + Command line: {0} + Command line: {0} + {0} is the command line used to run the application. + The same instance of 'CompositeExtensionFactory' is already registered "CompositeExtensionFactory" 的同一实例已注册 diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf index 266c6d62bb..61b767c5b8 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf @@ -162,6 +162,11 @@ 未知的選項 '--{0}' + + Command line: {0} + Command line: {0} + {0} is the command line used to run the application. + The same instance of 'CompositeExtensionFactory' is already registered 已註冊 'CompositeExtensonFactory' 的同一執行個體 diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/ArgumentArityTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/ArgumentArityTests.cs index 4f5e8edf93..d64a0895ae 100644 --- a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/ArgumentArityTests.cs +++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/ArgumentArityTests.cs @@ -58,7 +58,11 @@ public async Task ParseAndValidate_WhenOptionWithArityZeroIsCalledWithOneArgumen // Assert Assert.IsFalse(result.IsValid); - Assert.AreEqual("Option '--zeroArgumentsOption' from provider 'Microsoft Testing Platform command line provider' (UID: PlatformCommandLineProvider) expects no arguments", result.ErrorMessage, StringComparer.Ordinal); + Assert.AreEqual( + """ + Option '--zeroArgumentsOption' from provider 'Microsoft Testing Platform command line provider' (UID: PlatformCommandLineProvider) expects no arguments + Command line: --zeroArgumentsOption arg + """, result.ErrorMessage, StringComparer.Ordinal); } [TestMethod] @@ -74,7 +78,11 @@ public async Task ParseAndValidate_WhenOptionWithArityExactlyOneIsCalledWithTwoA // Assert Assert.IsFalse(result.IsValid); - Assert.AreEqual("Option '--exactlyOneArgumentsOption' from provider 'Microsoft Testing Platform command line provider' (UID: PlatformCommandLineProvider) expects at most 1 arguments", result.ErrorMessage); + Assert.AreEqual( + """ + Option '--exactlyOneArgumentsOption' from provider 'Microsoft Testing Platform command line provider' (UID: PlatformCommandLineProvider) expects at most 1 arguments + Command line: --exactlyOneArgumentsOption arg1 arg2 + """, result.ErrorMessage); } [TestMethod] @@ -90,7 +98,11 @@ public async Task ParseAndValidate_WhenOptionWithArityExactlyOneIsCalledWithoutA // Assert Assert.IsFalse(result.IsValid); - Assert.AreEqual("Option '--exactlyOneArgumentsOption' from provider 'Microsoft Testing Platform command line provider' (UID: PlatformCommandLineProvider) expects at least 1 arguments", result.ErrorMessage); + Assert.AreEqual( + """ + Option '--exactlyOneArgumentsOption' from provider 'Microsoft Testing Platform command line provider' (UID: PlatformCommandLineProvider) expects at least 1 arguments + Command line: --exactlyOneArgumentsOption + """, result.ErrorMessage); } [TestMethod] @@ -106,7 +118,11 @@ public async Task ParseAndValidate_WhenOptionWithArityZeroOrOneIsCalledWithTwoAr // Assert Assert.IsFalse(result.IsValid); - Assert.AreEqual("Option '--zeroOrOneArgumentsOption' from provider 'Microsoft Testing Platform command line provider' (UID: PlatformCommandLineProvider) expects at most 1 arguments", result.ErrorMessage); + Assert.AreEqual( + """ + Option '--zeroOrOneArgumentsOption' from provider 'Microsoft Testing Platform command line provider' (UID: PlatformCommandLineProvider) expects at most 1 arguments + Command line: --zeroOrOneArgumentsOption arg1 --zeroOrOneArgumentsOption arg2 + """, result.ErrorMessage); } [TestMethod] @@ -122,7 +138,11 @@ public async Task ParseAndValidate_WhenOptionWithArityOneOrMoreIsCalledWithoutAr // Assert Assert.IsFalse(result.IsValid); - Assert.AreEqual("Option '--oneOrMoreArgumentsOption' from provider 'Microsoft Testing Platform command line provider' (UID: PlatformCommandLineProvider) expects at least 1 arguments", result.ErrorMessage); + Assert.AreEqual( + """ + Option '--oneOrMoreArgumentsOption' from provider 'Microsoft Testing Platform command line provider' (UID: PlatformCommandLineProvider) expects at least 1 arguments + Command line: --oneOrMoreArgumentsOption + """, result.ErrorMessage); } [TestMethod] diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/CommandLineHandlerTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/CommandLineHandlerTests.cs index 1f0d4af132..9dcc7b1c67 100644 --- a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/CommandLineHandlerTests.cs +++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/CommandLineHandlerTests.cs @@ -151,7 +151,11 @@ public async Task ParseAndValidateAsync_InvalidOption_ReturnsFalse() // Assert Assert.IsFalse(result.IsValid); - Assert.AreEqual("Option '--diagnostic-verbosity' has invalid arguments: '--diagnostic-verbosity' expects a single level argument ('Trace', 'Debug', 'Information', 'Warning', 'Error', or 'Critical')", result.ErrorMessage); + Assert.AreEqual( + """ + Option '--diagnostic-verbosity' has invalid arguments: '--diagnostic-verbosity' expects a single level argument ('Trace', 'Debug', 'Information', 'Warning', 'Error', or 'Critical') + Command line: --diagnostic-verbosity r + """, result.ErrorMessage); } [TestMethod] @@ -167,7 +171,31 @@ public async Task ParseAndValidateAsync_InvalidArgumentArity_ReturnsFalse() // Assert Assert.IsFalse(result.IsValid); - Assert.AreEqual("Option '--help' from provider 'Platform command line provider' (UID: PlatformCommandLineProvider) expects no arguments", result.ErrorMessage); + Assert.AreEqual( + """ + Option '--help' from provider 'Platform command line provider' (UID: PlatformCommandLineProvider) expects no arguments + Command line: --help arg + """, result.ErrorMessage); + } + + [TestMethod] + public async Task ParseAndValidateAsync_InvalidArgumentArityWithToolName_IncludesFullCommandLine() + { + // Arrange + string[] args = ["TestProject.dll", "--dotnet-test-pipe", "pipe", "extra"]; + CommandLineParseResult parseResult = CommandLineParser.Parse(args, new SystemEnvironment()); + + // Act + ValidationResult result = await CommandLineOptionsValidator.ValidateAsync(parseResult, _systemCommandLineOptionsProviders, + _extensionCommandLineOptionsProviders, new Mock().Object); + + // Assert + Assert.IsFalse(result.IsValid); + Assert.AreEqual( + """ + Option '--dotnet-test-pipe' from provider 'Platform command line provider' (UID: PlatformCommandLineProvider) expects at most 1 arguments + Command line: TestProject.dll --dotnet-test-pipe pipe extra + """, result.ErrorMessage); } [TestMethod] @@ -228,7 +256,11 @@ public async Task ParseAndValidateAsync_UnknownOption_ReturnsFalse() // Assert Assert.IsFalse(result.IsValid); - Assert.AreEqual("Unknown option '--x'", result.ErrorMessage); + Assert.AreEqual( + """ + Unknown option '--x' + Command line: --x + """, result.ErrorMessage); } [TestMethod] From 05af34fea4d0ec3f02b0b2948ce48b38799da911 Mon Sep 17 00:00:00 2001 From: Copilot <223556219+Copilot@users.noreply.github.com> Date: Sat, 16 May 2026 13:53:47 +0200 Subject: [PATCH 3/4] Update acceptance test for new Command line: line in validation errors Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../HelpInfoTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs index 202fbc81b6..91db8fd26e 100644 --- a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs +++ b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs @@ -113,6 +113,7 @@ public async Task Help_WhenNoExtensionRegisteredAndUnknownOptionIsSpecified_Outp const string wildcardMatchPattern = $""" Microsoft.Testing.Platform v* Unknown option '--{UnknownOption}' +Command line: * Usage {TestAssetFixture.NoExtensionAssetName}* [option providers] [extension option providers] Execute a .NET Test Application. Options: From 737f19d9526786d1ad0b46068b6d08cf0335d214 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 16 May 2026 14:32:46 +0000 Subject: [PATCH 4/4] Use exact command line in help info test Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com> --- .../HelpInfoTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs index 91db8fd26e..0dc52a14c7 100644 --- a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs +++ b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs @@ -113,7 +113,7 @@ public async Task Help_WhenNoExtensionRegisteredAndUnknownOptionIsSpecified_Outp const string wildcardMatchPattern = $""" Microsoft.Testing.Platform v* Unknown option '--{UnknownOption}' -Command line: * +Command line: --no-ansi --no-progress -{UnknownOption} Usage {TestAssetFixture.NoExtensionAssetName}* [option providers] [extension option providers] Execute a .NET Test Application. Options: