I have experimented with a specific approach, and here are my insights:
1. Initially, I attempted to use mingwx64 with a C# WinUI3 Application. While mingwx64 successfully exports DLLs and .h headers, integrating these directly into C# is challenging due to the lack of a straightforward method for calling C functions. This typically necessitates code generation tools to create C# P/Invoke methods from .h files, a daunting task with extensive headers (over 10,000 lines). I experimented with
Cysharp csbindgen, which was effective, but introduced multiple conversion layers (Kotlin -> C Header -> P/Invoke). This process can lead to significant loss of methods/information, and troubleshooting conversion errors can be difficult.
2. To streamline the process, I explored mingwx64 in conjunction with a C++ WinUI3 Application. This approach proved functional but introduced complexity due to the prevalence of pointers, particularly for functions with generic return types. Writing wrappers for these functions was cumbersome, and many classes were not readily available in the mingwx64 headers, requiring additional manual effort.
3. Consequently, I considered using
ikvm.net. Integrating a fat jar with ikvm and a C# WinUI3 Application yielded excellent results. This setup allowed direct use of Kotlin classes and functions in C#, with the sole exception being the conversion of 'suspend' to 'Task'. However, ikvm is limited to JDK 8 support. While this is currently manageable, it could pose challenges as more libraries transition to JDK 11. Attempts to use
bsideup's Jabel for converting JDK 11 jars to JDK 8 were unsuccessful.