-
Notifications
You must be signed in to change notification settings - Fork 627
Case insensitive user text input comparison #1960
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
base: main
Are you sure you want to change the base?
Case insensitive user text input comparison #1960
Conversation
@microsoft-github-policy-service agree |
patriksvensson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great first PR, but there are some changes I would like to see before I merge this 👍
src/Tests/Spectre.Console.Tests/Unit/Prompts/TextPromptTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Patrik Svensson <[email protected]>
Co-authored-by: Patrik Svensson <[email protected]>
Co-authored-by: Patrik Svensson <[email protected]>
Co-authored-by: Patrik Svensson <[email protected]>
|
Thanks for the feedback! All suggestions applied. |
fixes #1906
Changes
Summary
This PR makes
TextPrompt<string>case-insensitive when matching user input against defined choices. Previously, inputs such as"yes"would fail to match"Yes".What this change does
When the
TextPrompt's generic is a string and the user did not explicitly provide a comparer, it automatically configures_comparertoStringComparer.OrdinalIgnoreCase.Adds a theory-based test to verify case-insensitive matching.
All existing behavior remains unchanged for non-string
TextPrompt<T>usage.Implementation Notes
Added a
typeof(T) == typeof(string)check inTextPrompt<T>to detect string-based prompts._compareris set toStringComparison.OrdinalIgnoreCaseonly if the user does not supply a comparer.