Skip to content

C#: Pass classpath via environment variable instead of -cp argument#7345

Merged
macsux merged 4 commits intomainfrom
macsux/csharp-test-fix
Apr 11, 2026
Merged

C#: Pass classpath via environment variable instead of -cp argument#7345
macsux merged 4 commits intomainfrom
macsux/csharp-test-fix

Conversation

@macsux
Copy link
Copy Markdown
Contributor

@macsux macsux commented Apr 10, 2026

Summary

  • Passes the Java classpath via the CLASSPATH environment variable instead of the -cp command-line argument when launching the RPC test server process
  • Avoids command-line length limits on Windows, where long classpaths can exceed the maximum argument length

Test plan

  • Run C# xUnit tests (dotnet test from rewrite-csharp/csharp/)
  • Verify RPC test server starts correctly on both Windows and Unix

Avoids command-line length limits on Windows by setting the CLASSPATH
environment variable instead of passing it as a -cp argument to the
Java RPC test server process.
macsux added 2 commits April 10, 2026 14:17
PreconditionsCheckTest expects LocalUsesType (local fallback) but when
RPC tests run first, RewriteRpcServer.Current is non-null, causing
UsesType to return an RpcVisitor that fails silently. Save/restore the
static in the test fixture to ensure isolation.
…ava via RPC

UsesType/UsesMethod now require an RPC connection and delegate to Java's
HasType/HasMethod. This eliminates the static state leak that caused flaky
test failures — tests using preconditions are inherently RPC-bound and must
run sequentially via RpcRewriteTest/[Collection("RPC")].

Also fix rpcTestClasspath to include processResources output directories so
Java's ServiceLoader discovers CSharpRpcCodec when the C# test fixture
spawns a Java RPC process.
@macsux macsux marked this pull request as ready for review April 11, 2026 00:15
@macsux macsux merged commit 317e4b9 into main Apr 11, 2026
1 check passed
@macsux macsux deleted the macsux/csharp-test-fix branch April 11, 2026 00:16
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant