diff --git a/Engine/Settings.cs b/Engine/Settings.cs index 4f9dcd546..7b98b54b8 100644 --- a/Engine/Settings.cs +++ b/Engine/Settings.cs @@ -395,7 +395,7 @@ private void parseSettingsHashtable(Hashtable settingsHashtable) var settings = GetDictionaryFromHashtable(settingsHashtable); foreach (var settingKey in settings.Keys) { - var key = settingKey.ToLower(); + var key = settingKey.ToLowerInvariant(); object val = settings[key]; switch (key) { diff --git a/Tests/Engine/SettingsTest/Issue1095/Issue1095.tests.ps1 b/Tests/Engine/SettingsTest/Issue1095/Issue1095.tests.ps1 new file mode 100644 index 000000000..d768a7c85 --- /dev/null +++ b/Tests/Engine/SettingsTest/Issue1095/Issue1095.tests.ps1 @@ -0,0 +1,20 @@ +Describe "Issue 1095: An exception is thrown when CurrentCulture is Turkish (tr-TR)" { + It "Should not throw an exception when CurrentCulture is tr-TR" { + # https://github.com/PowerShell/PSScriptAnalyzer/issues/1095 + + $initialCulture = Get-Culture + $initialUICulture = Get-UICulture + + { + $trTRculture = [System.Globalization.CultureInfo]::GetCultureInfo('tr-TR') + [System.Threading.Thread]::CurrentThread.CurrentUICulture = $trTRculture + [System.Threading.Thread]::CurrentThread.CurrentCulture = $trTRculture + Invoke-Formatter "`$test" -ErrorAction Stop + + } | Should -Throw -Not + + [System.Threading.Thread]::CurrentThread.CurrentCulture = $initialCulture + [System.Threading.Thread]::CurrentThread.CurrentUICulture = $initialUICulture + + } +} \ No newline at end of file