How do I convert an array pointer returned by a native library into a class in C#

Given this delegate:
public delegate* unmanaged[Cdecl]<lib_kref_Resource, lib_kref_kotlin_Array> listUsers;

With the next struct definition (generated with ClangSharpPInvokeGenerator):

typedef struct {
  lib_KNativePtr pinned;
} lib_kref_kotlin_Array;

public unsafe partial struct lib_kref_Resource
{
    public void* pinned;
}

And knowing that the kotlin code is like this:

class Resource {

    class User(
        val id: String,
        val name: String,
        val email: String
    )
    
    fun getUsers(): Array<User> {
        return arrayOf(User("user-id", "user-name", "user-email"))
    }
}

How can I convert the pointer? returned by the listUser function into a User[] array in C#?

1 Like