This repository was archived by the owner on Aug 27, 2026. It is now read-only.
Commit bbd75c1
[generator] Replace hyphens in parameter names (#498)
Context: #464
Context: 7a309c4
Use of [Kotlin][0] can result in some "weird" method names and
parameter names in Java bytecode, in particular names which contain
spaces:
// Kotlin
abstract class Example {
public fun `method spaces`(`parameter spaces`: Double) {
}
}
Run that through `kotlinc` and `javap`, and...there's a parameter
name with spaces!
$ kotlinc -java-parameters hello.kt
$ javap Example.class
Classfile Example.class
...
public abstract class Example
...
public final void method spaces(double);
...
MethodParameters:
Name Flags
parameter spaces
...which is a sure fire way to confuse things.
Update `XmlApiImporter.EnsureValidIdentifier()` so that it uses
`IdentifierValidator.CreateValidIdentifier()` (7a309c4) to turn
potentially invalid strings such as `method spaces` into valid C#
identifiers such as `method_spaces`, which also ensures that method
names and constructor names are appropriately fixed.
Additionally, update `XmlApiImporter.CreateParameter()` so that it
now uses `EnsureValidIdentifier()`, ensuring it is consistent with
method and constructor name correction.
[0]: https://kotlinlang.org1 parent 68062a7 commit bbd75c1
2 files changed
Lines changed: 12 additions & 2 deletions
File tree
- tools/generator
- Java.Interop.Tools.Generator.Importers
- Tests/Unit-Tests
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
270 | 271 | | |
271 | 272 | | |
272 | 273 | | |
273 | | - | |
| 274 | + | |
274 | 275 | | |
275 | 276 | | |
276 | 277 | | |
| |||
294 | 295 | | |
295 | 296 | | |
296 | 297 | | |
297 | | - | |
| 298 | + | |
298 | 299 | | |
299 | 300 | | |
300 | 301 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
83 | 92 | | |
84 | 93 | | |
85 | 94 | | |
| |||
0 commit comments