Skip to content

Commit

Permalink
Avoid repetitive string.Format call for every character of command-li…
Browse files Browse the repository at this point in the history
…ne options (#4264)
  • Loading branch information
Youssef1313 authored Dec 7, 2024
1 parent d269367 commit 8dc8b14
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8dc8b14

Please sign in to comment.