From c0d5ee21408ddd99a3e3603354eb5fa0371e5a1d Mon Sep 17 00:00:00 2001 From: DoctorKrolic <70431552+DoctorKrolic@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:53:41 +0300 Subject: [PATCH] Print diagnostics in invariant culture (English error messages) in assert text (#72816) --- .../Test/Core/Diagnostics/DiagnosticDescription.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Compilers/Test/Core/Diagnostics/DiagnosticDescription.cs b/src/Compilers/Test/Core/Diagnostics/DiagnosticDescription.cs index 01817d73a198a..89d683b133610 100644 --- a/src/Compilers/Test/Core/Diagnostics/DiagnosticDescription.cs +++ b/src/Compilers/Test/Core/Diagnostics/DiagnosticDescription.cs @@ -6,17 +6,18 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; +using System.Globalization; using System.Linq; using System.Text; using System.Text.RegularExpressions; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Text; +using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; -using Roslyn.Test.Utilities; -using Microsoft.CodeAnalysis.PooledObjects; -using Microsoft.CodeAnalysis.CSharp; -using System.Collections.Immutable; namespace Microsoft.CodeAnalysis.Test.Utilities { @@ -518,7 +519,7 @@ public static string GetAssertText(DiagnosticDescription[] expected, IEnumerable for (i = 0; e.MoveNext(); i++) { Diagnostic d = e.Current; - string message = d.ToString(); + string message = d.ToString(CultureInfo.InvariantCulture); if (Regex.Match(message, @"{\d+}").Success) { Assert.True(false, "Diagnostic messages should never contain unsubstituted placeholders.\n " + message); @@ -533,7 +534,7 @@ public static string GetAssertText(DiagnosticDescription[] expected, IEnumerable { Indent(assertText, indentDepth); assertText.Append("// "); - assertText.AppendLine(d.ToString()); + assertText.AppendLine(message); var l = d.Location; if (l.IsInSource) {