Skip to content
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

ParameterExtractor of cultureInfo issue #2350

Closed
samiozer opened this issue Jan 21, 2023 · 3 comments · Fixed by #2351
Closed

ParameterExtractor of cultureInfo issue #2350

samiozer opened this issue Jan 21, 2023 · 3 comments · Fixed by #2351

Comments

@samiozer
Copy link

samiozer commented Jan 21, 2023

There is a CultureInfo problem in the process of finding the "@blabla" parameters defined in the script text with regex.
For example
A parameter named "@testIId" cannot be found in script text when CulturerInfo is "tr-TR". The character "I" has always been a problem for this Culture :) RegexOptions.CultureInvariant can be added as a solution.

Old

private static readonly Regex ParameterExtractor = new Regex(@"@(?<paramName> ([a-z]|_) ([a-z]|_|\d)*)", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);

New

private static readonly Regex ParameterExtractor = new Regex(@"@(?<paramName> ([a-z]|_) ([a-z]|_|\d)*)", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.CultureInvariant);
@mgravell
Copy link
Collaborator

Yep, totally understood, and you're absolutely right - this should be invariant. Thanks for reporting. Will happily take a PR, or I will commit to taking this at the start of the week.

NickCraver added a commit that referenced this issue Jan 22, 2023
This changes the regex to use RegexOptions.CultureInvariant and adds an easy way to do tests like this in the future with `[Fact, TestCulture("tr-TR")]` for example, which will set and restore the culture for a specific test.
@NickCraver
Copy link
Collaborator

This gave me an idea on testing I wanted to poke on (culture via attribute for test-scoping), turns out there is some prior art and it works pretty well I think, made a PR here: #2351

@samiozer
Copy link
Author

I couldn't create PR because I had urgent work at the weekend. thanks, @NickCraver.

NickCraver added a commit that referenced this issue Jan 24, 2023
)

This changes the regex to use `RegexOptions.CultureInvariant` and adds an easy way to do tests like this in the future with `[Fact, TestCulture("tr-TR")]` for example, which will set and restore the culture for a specific test.

Before/after break/fix test included for the Turkish case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants