C# test OutputThatDoesNotParseFails fails under non-English locales

Open Beginner friendly
#9,835 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
79/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
testing

Research direction

Read rewrite-csharp/csharp/OpenRewrite.Tests/Core/ParserShapedTreesTests.cs around lines 88–89 and run the filtered OutputThatDoesNotParseFails test with DOTNET_CLI_UI_LANGUAGE set to ko-KR or ja-JP. Check how the assertion can verify the diagnostic code and invalid source without relying on localized message text. Done means the test passes across the listed locales while still checking the parsing failure.

Written by the indexing model from the issue text.

Description

Description

The C# test ParserShapedTreesTests.OutputThatDoesNotParseFails passes with DOTNET_CLI_UI_LANGUAGE=en-US, but fails with ko-KR and ja-JP.

The test appears to be locale-dependent because it expects a hardcoded English Roslyn diagnostic message:

ParserShapedTreesTests.cs:88–89

Assert.Contains(
    "\n    the text it prints doesn't parse: CS1002 ; expected at `return null null;`\n",
    failure.Message);

For example, the Korean diagnostic uses CS1002 ;이 필요합니다. instead of CS1002 ; expected.

Steps to reproduce

Run the following command from the repository root, changing the locale between en-US, ko-KR, and ja-JP:

DOTNET_CLI_UI_LANGUAGE=ko-KR \
dotnet test rewrite-csharp/csharp/OpenRewrite.Tests/OpenRewrite.Tests.csproj \
  --filter "FullyQualifiedName~OutputThatDoesNotParseFails"
Locale Result
en-US PASS
ko-KR FAIL
ja-JP FAIL

The failure occurs at ParserShapedTreesTests.cs:88 with Assert.Contains() Failure: Sub-string not found.

Possible solutions

Depending on the intended purpose of the test:

  1. Locale-independent assertion: If the test is intended to verify a parsing failure, check the diagnostic code (CS1002) and invalid source (return null null;) separately, without depending on localized diagnostic text.
  2. Explicit English locale: If the full diagnostic message must be verified, explicitly control the diagnostic culture in the test or document DOTNET_CLI_UI_LANGUAGE=en-US as a workaround for contributors.

Environment

  • macOS ARM64
  • .NET SDK 10.0.404
  • Commit: a848f9928ea8487d0017616cbc0b960ece63bdc3
Dominant language
Java
Stars
3.9k
Forks
599
Avg merge
9h 38m
Merged PRs (30d)
557

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openrewrite/rewrite

All issues in openrewrite/rewrite

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.