soygul/NBug — pull request #42 by DoctorDump (2014-09-17 10:33:06+00:00)
Title: Exception messages in English

Exception messages should be sent in English language rather than on
user language.

The example of Culture impact to exception:

Russian locale:

System.IO.FileNotFoundException: Some message
__Имя файла__: 'test.zip'
__в__ NBug.Examples.WinForms.MainForm.CrashButton_Click(Object sender, EventArgs e) в MainForm.cs:__строка__ 54
__в__ System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
...

InvariantCulture:

System.IO.FileNotFoundException: Some message
__File name__: 'test.zip'
__at__ NBug.Examples.WinForms.MainForm.CrashButton_Click(Object sender, EventArgs e) in MainForm.cs:__line__ 54
__at__ System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
...

Git shows diff incorrectly. Real change is simple:

var oldCulture = Thread.CurrentThread.CurrentCulture;
var oldUICulture = Thread.CurrentThread.CurrentUICulture;
try
{
// Prefer messages in English, instead of in language of the user.
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

... Old code ...
}
finally
{
Thread.CurrentThread.CurrentCulture = oldCulture;
Thread.CurrentThread.CurrentUICulture = oldUICulture;
}