Skip to content

Map Throwable.getMessage() to Exception.Message (#165) - #174

Merged
paulirwin merged 1 commit into
masterfrom
fix/165-getmessage-to-message
Aug 17, 2026
Merged

Map Throwable.getMessage() to Exception.Message (#165)#174
paulirwin merged 1 commit into
masterfrom
fix/165-getmessage-to-message

Conversation

@paulirwin

Copy link
Copy Markdown
Owner

Fixes #165.

Java's e.getMessage() converted to e.GetMessage(), which doesn't compile against C#'s Exception.

TypeHelper.TryTransformMethodCall already had a ReplaceMethodByProperty helper backing lengthLength and sizeCount — that's exactly the method-call-to-property-access handling the issue noted was needed, so getMessageMessage slots in there rather than into the name-only ReplaceCommonMethodNames table.

The case is guarded on zero arguments, matching the surrounding cases, so an unrelated obj.getMessage(i) still converts to a normal method call.

Tests

  • Two cases in ConvertExpressionTests (e.getMessage()e.Message, and the arity-guard negative case).
  • A new Resources/ExceptionGetMessage.java fixture wired into FullIntegrationTests, so the generated C# is compiled and run: it throws an IllegalArgumentException, catches it, and asserts the printed message.

Full suite passes at 363 tests.

Note

Java's Throwable has sibling accessors with the same problem (getLocalizedMessage(), getCause()). This PR stays scoped to getMessage() as the issue described; happy to follow up on the others.

🤖 Generated with Claude Code

Java's `e.getMessage()` converted to `e.GetMessage()`, which does not
compile against C#'s `Exception`. Route it through the existing
`TryTransformMethodCall` property-replacement path, alongside `length`
and `size`, so it becomes the `Message` property access.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@paulirwin
paulirwin enabled auto-merge (squash) August 17, 2026 19:08
@paulirwin
paulirwin merged commit 673e6cb into master Aug 17, 2026
5 checks passed
@paulirwin
paulirwin deleted the fix/165-getmessage-to-message branch August 17, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Throwable.getMessage() is not mapped to Exception.Message

1 participant