Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print diagnostics in invariant culture (English error messages) in assert text #72816

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/Compilers/Test/Core/Diagnostics/DiagnosticDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
Expand All @@ -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)
{
Expand Down