Repository navigation
Commit 673e6cb
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 `length`→`Length` and
`size`→`Count` — that's exactly the method-call-to-property-access
handling the issue noted was needed, so `getMessage`→`Message` 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](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 5868599 commit 673e6cb
4 files changed
Lines changed: 23 additions & 0 deletions
File tree
- JavaToCSharp.Tests
- Resources
- JavaToCSharp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
276 | 283 | | |
277 | 284 | | |
278 | 285 | | |
| |||
0 commit comments