-
Couldn't load subscription status.
- Fork 402
Fix PSSA for Turkish culture and tests when culture is not en-US #1099
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
Conversation
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.
in PowerShell, we've been instructed to use StringComparer.OrdinalIgnoreCase. I'm thinking that we should do that here as well unless there's a really good reason not to.
http://msdn.microsoft.com/en-us/library/system.stringcomparer.ordinalignorecase.aspx
http://msdn.microsoft.com/en-us/library/system.stringcomparer.invariantcultureignorecase.aspx
…nalyzer into CultureFixes # Conflicts: # Engine/Generic/ModuleDependencyHandler.cs
|
Ok, I've made it use |
fix also ToLower call in new compatibility module # Conflicts: # Engine/ScriptAnalyzer.cs # Engine/Settings.cs # tools/appveyor.psm1
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.
LGTM
| goto default; | ||
| RuleName = (name.Argument as StringConstantExpressionAst).Value; | ||
| } | ||
| else if (argumentName.Equals("rulesuppressionid", StringComparison.OrdinalIgnoreCase)) |
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.
There's a lot of else ifs in this method and I had to read all of them to check that some kind of state isn't being manipulated by all of them. Would it be easier to use return?
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.
Hmm, one would have to move it into a function and other variables would need to be passed to it and there is no else, meaning the caller of it would need an if (returnValue != null) check. I don't think the juice is worth the squeeze here, especially for code that is not likely to be changed and this change is not adding any functionality that would justify such a refactor (any refactor also comes with the risk of a regression, I am not saying we should not change in general, but there seems to be little benefit to me here). Even if previous code is not the best, as long as it does not appear to be dangerously bad, I'd not change it too much in this instance
| break; | ||
| default: | ||
| return false; | ||
| severityList.AddRange(values); |
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.
It strikes me that it would be simpler to just return true here and in the next clause and just return false at the end by default
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.
yes, I agree, I''ve addressed that in this commit
| break; | ||
|
|
||
| default: | ||
| if (settingKey.Equals("severity", StringComparison.OrdinalIgnoreCase) || |
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.
I was going to suggest changes here, but I keep thinking about the rest of the file so I might open a PR instead
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.
I'm going to defer this. The code works for now, but I'd really like to work on boiling down some common functionality eventually -- something we can work out in the future.
Co-Authored-By: bergmeister <[email protected]>
…nalyzer into CultureFixes
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.
lgtm
…erShell#1099) * Fix Parsing of settings that occurs when using turkish culture * use german culture before running tests to exhibit failures * set ui culture as well * fix communityanalyzer for turkish culture * fix ProvideCommentHelp for turkish culture (i problem again) * update comments * fix for import-localizedDatabug in pscore (opened issue 8219 in ps core repo) * change to UI culture * use invariant culture comparison instead of tolowerinvariant and revert change where it is not needed * finish with comments * Use OrdinalIgnoreCase * revert accidental change from 2 commits before * trigger ci * Apply suggestions from code review Co-Authored-By: bergmeister <[email protected]> * Use else-less approach to address PR comment
PR Summary
Import-LocalizedDatafrom a culture that is noten-US. This is a PowerShell Core bug, I also raised an issue that I reference in the commentToLower()orToUppercan return a special Turkishicharacter that then does not pass the comparison when compared to a normali. The approach is to eliminate the need for it by using culture invariant comparison where possible and otherwise callingToLowerInvarian().ToLowercalls in PowerShell since PowerShell is case insensitivePR Checklist
.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.