2

I am trying to bind a Kotlin package which is using the Kotlin.Result type. If I look at the .aar with the Java-Decompiler tool I see that some methods have return types like Result<String> or Result<SomeClass>.

How can I get the actual result from the Result, because the Xamarin binding (Xamarin.Kotlin.StdLib 1.7.20.1) does't have a generic implementation and is missing the methods described on the Kotlin website (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/).

Is there a way to get the generic type of the Kotlin.Result class in Xamarin.Android.

I have looked at older and newer versions of the nuget package Xamarin.Kotlin.StdLib. In an older version the KotlinKt class has had a method ThrowIfFailure (or something like this), but this is missing in the newer releases.

For now I only can resolve the Result<string> type by converting the Result to a string, using the ToString extension, and check if it starts with failed or success. If it is failed then I throw an exception else I remove "succes(" and ")" from the result so I get the string value. This doesn't work if the type is class with multiple properties.

albertb22
  • 21
  • 1

0 Answers0