-
Notifications
You must be signed in to change notification settings - Fork 64
Closed
Milestone
Description
I have noticed that binding Kotlin code results in bad code. For example, I am binding okio v2.0.0
There are a few bits of code that cannot be compiled:
- It tries to bind classes with a
-prefix. This looks to be a way to mark them as deprecated or internal or something. This is easy to remove by:
<remove-node path="/api/package/class[starts-with(@name,'-')]" /> - It tries to bind methods with a
-prefix, again easy to remove with:
<remove-node path="/api/package/class/method[starts-with(@name,'-')]" /> - It tries to bind methods with
$in the parameter names:
public static final int codePointAt(@NotNull byte[] $receiver, int index)
There are other areas where it works fine, so this looks to be just in the finally blocks. I am able to fix this by setting themanagedName:
<attr path="/api/package[@name='okio']/class/method[parameter[1][@name='$receiver']]/parameter[1]" name="managedName">receiver</attr>
Without this adjustment, the generator results in partially corrected code:- Declaration:
public static unsafe int CodePointAt (byte[] _receiver_, int index) - Code:
try { ... } finally { if ($receiver != null) { ... } }
- Declaration:
There are also cases where this could be improved overall:
- With Kotlin, you can have extension methods (the reason for the
$receiverparameter name). This means that Xamarin could potentially automatically generate extension methods - or have the option to do so. - There are also cases where
internalmembers are public in C#:
internal val AssertionError.isAndroidGetsocknameError: Boolean get() { ... }
https://github.com/square/okio/blob/okio-parent-2.0.0/okio/jvm/src/main/java/okio/Okio.kt#L212
I am working on a tool that runs after the api.xml is created to create a transforms.xml file that tries to fix and resolve members. A very rough thing that seems to be working: xamarin/XamarinComponents#642
Gitii
Metadata
Metadata
Assignees
Labels
No labels