Merge pull request #5810 from tamasvajk/feature/culture

C#: Use invariant culture in the extractor
This commit is contained in:
Tamás Vajk
2021-05-04 13:09:38 +02:00
committed by GitHub
3 changed files with 21 additions and 0 deletions

View File

@@ -11,6 +11,8 @@ using System.Diagnostics;
using System.Threading.Tasks;
using Semmle.Util.Logging;
using System.Collections.Concurrent;
using System.Globalization;
using System.Threading;
namespace Semmle.Extraction.CSharp
{
@@ -52,6 +54,21 @@ namespace Semmle.Extraction.CSharp
public void MissingType(string type) { }
}
/// <summary>
/// Set the application culture to the invariant culture.
///
/// This is required among others to ensure that the invariant culture is used for value formatting during TRAP
/// file writing.
/// </summary>
public static void SetInvariantCulture()
{
var culture = CultureInfo.InvariantCulture;
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
}
/// <summary>
/// Command-line driver for the extractor.
/// </summary>