NordSecurity / uniffi-bindgen-cs

C# bindings generator for uniffi-rs
https://github.com/NordSecurity/uniffi-bindgen-cs
Mozilla Public License 2.0
109 stars 21 forks source link

External types are not supported #40

Open arg0d opened 1 year ago

arg0d commented 1 year ago

External types are not supported right now, because C# has limitations regarding custom types. Custom types are implemented as C# type aliases with using directive using A = B;. The using directive is file local, and the type alias is not visible outside the file its defined in. So, trying to use external types with custom types results in broken code. It might be possible to external types referencing custom types, but we haven't had the time to explore this yet. Using library mode in uniffi 0.24, it might be possible to dereference external types across UDL boundary, and emit the underlying type directly without needing to reference type alias from another C# file.

Supporting external types without referencing custom types should be possible, but some kind of warning should be implemented to warn the users of this issue. Also, upstream tests can't be used, because the tests use external types to reference custom types. Supporting external types is not a priority for us right now, but contributions are welcome.