Skip to content

Commit 5eea613

Browse files
authored
Fix test failures on non-english systems (#8928)
1 parent e5982ae commit 5eea613

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/HotChocolate/Core/test/Types.Analyzers.Tests/TestHelper.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System.Collections.Immutable;
22
using System.Diagnostics.CodeAnalysis;
3+
using System.Globalization;
4+
using System.Runtime.CompilerServices;
35
using System.Text;
46
using System.Text.Encodings.Web;
57
using System.Text.Json;
@@ -314,4 +316,16 @@ private static void AddDiagnosticsToSnapshot(
314316

315317
[GeneratedRegex("MiddlewareFactories([a-z0-9]{32})")]
316318
private static partial Regex MiddlewareFactoryHashRegex();
319+
320+
internal static class ForceInvariantDefaultCultureModuleInitializer
321+
{
322+
[ModuleInitializer]
323+
internal static void Initialize()
324+
{
325+
// Compile errors are localized, so enforce a common default culture,
326+
// since otherwise the snapshot comparison may fail
327+
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
328+
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
329+
}
330+
}
317331
}

0 commit comments

Comments
 (0)