Skip to content

Commit bec4c22

Browse files
committed
tr-TR culture problem fix #1095
1 parent 1f855ac commit bec4c22

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Engine/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ private void parseSettingsHashtable(Hashtable settingsHashtable)
395395
var settings = GetDictionaryFromHashtable(settingsHashtable);
396396
foreach (var settingKey in settings.Keys)
397397
{
398-
var key = settingKey.ToLower();
398+
var key = settingKey.ToLower(CultureInfo.GetCultureInfo("en-US"));
399399
object val = settings[key];
400400
switch (key)
401401
{
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Describe "Issue 1095: An exception is thrown when CurrentCulture is Turkish (tr-TR)" {
2+
It "Should not throw an exception when CurrentCulture is tr-TR" {
3+
# https://github.com/PowerShell/PSScriptAnalyzer/issues/1095
4+
5+
6+
{
7+
$trTRculture = [System.Globalization.CultureInfo]::GetCultureInfo('tr-TR')
8+
Set-Culture $trTRculture
9+
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $trTRculture
10+
[System.Threading.Thread]::CurrentThread.CurrentCulture = $trTRculture
11+
Invoke-Formatter "`$test" -ErrorAction Stop
12+
13+
} | Should -Throw -Not
14+
15+
BeforeEach {
16+
$initialCulture = Get-Culture
17+
$initialUICulture = Get-UICulture
18+
}
19+
20+
AfterEach {
21+
Set-Culture $initialCulture
22+
[System.Threading.Thread]::CurrentThread.CurrentCulture = $initialCulture
23+
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $initialUICulture
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)