You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all, first thanks for the amazing work on the bindings generator, we're using it as a base for our shared library across Android, iOS and web and it's been incredibly helpful so far.
Today I was trying to create a fake of one of our Rust classes in Kotlin and I saw that for every exported type there is a "TypeNameInterface" interface or protocol created. I started creating the fake for this interface but I had to stop as soon as I got to a function that returned a struct with some impl from our project since the function returned the concrete generated type that extends from FFIObject instead of the interface.
interface Bar {
void bar();
}
interface Foo {
Bar foo();
}
If I tried to create a fake of that class, I couldn't do it because the Foo class is not open, so you can't extend it.
There is not way to return a fake that extends from the interface since the return type is the concrete class, not the interface.
The problem seems to be the same on iOS, but with protocols instead of interfaces. Maybe I'm doing something wrong?
It's probably worth noting that while this might work for unit testing using some mocking library, which I haven't really tested yet, my current use case is that one of our Android views indirectly calls our Rust code to retrieve some values and this causes some tools such as the UI layout preview to crash when they try to load the generated native library that the concrete generated classes use underneath. So my goal is to have those fakes not only for testing, but for other use cases where I can't load the native library.
┆Issue is synchronized with this Jira Task
┆friendlyId: UNIFFI-202
The text was updated successfully, but these errors were encountered:
It does make sense that the interface should be described in terms of other interfaces where possible, but it just hasn't bitten us yet. IOW, I think a PR for this is likely to be accepted.
Hi all, first thanks for the amazing work on the bindings generator, we're using it as a base for our shared library across Android, iOS and web and it's been incredibly helpful so far.
Today I was trying to create a fake of one of our Rust classes in Kotlin and I saw that for every exported type there is a "TypeNameInterface" interface or protocol created. I started creating the fake for this interface but I had to stop as soon as I got to a function that returned a struct with some impl from our project since the function returned the concrete generated type that extends from
FFIObject
instead of the interface.This would create:
Foo
class is not open, so you can't extend it.The problem seems to be the same on iOS, but with protocols instead of interfaces. Maybe I'm doing something wrong?
It's probably worth noting that while this might work for unit testing using some mocking library, which I haven't really tested yet, my current use case is that one of our Android views indirectly calls our Rust code to retrieve some values and this causes some tools such as the UI layout preview to crash when they try to load the generated native library that the concrete generated classes use underneath. So my goal is to have those fakes not only for testing, but for other use cases where I can't load the native library.
┆Issue is synchronized with this Jira Task
┆friendlyId: UNIFFI-202
The text was updated successfully, but these errors were encountered: