diff --git a/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOption.cs b/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOption.cs index 398da42025..aa3cf47b5e 100644 --- a/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOption.cs +++ b/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOption.cs @@ -29,9 +29,10 @@ internal CommandLineOption(string name, string description, ArgumentArity arity, Guard.NotNullOrWhiteSpace(description); ArgumentGuard.Ensure(arity.Max >= arity.Min, nameof(arity), PlatformResources.CommandLineInvalidArityErrorMessage); + string errorMessage = string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineInvalidOptionName, name); for (int i = 0; i < name.Length; i++) { - ArgumentGuard.Ensure(char.IsLetterOrDigit(name[i]) || name[i] == '-' || name[i] == '?', nameof(name), string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineInvalidOptionName, name)); + ArgumentGuard.Ensure(char.IsLetterOrDigit(name[i]) || name[i] == '-' || name[i] == '?', nameof(name), errorMessage); } Name = name;