jrouaix / csharp-expr-rs

c# expression parser in Rust [very experimental]
MIT License
8 stars 0 forks source link

MarshalDirectiveException : Method's type signature is not PInvoke compatible. #2

Open jrouaix opened 4 years ago

jrouaix commented 4 years ago

Well, i'm having troubles with FFI on netcoreapp2 vs all good on netcoreapp3

image

[DllImport(LIB_NAME, CharSet = CharSet.Ansi)]
public static extern FFIExecResult ffi_exec_expr(FFIExpressionHandle ptr, FFIIdentifierKeyValue[] identifier_values, UIntPtr identifier_values_len);

I narrowed the problem to the function return type :

[StructLayout(LayoutKind.Sequential)]
internal unsafe struct FFIExecResult
{
    [MarshalAs(UnmanagedType.I1)]
    public bool is_error;
    public IntPtr content;

    public FFIStringHandle GetContent() => new FFIStringHandle(content);
}

Is there some other way to hack through this on netcore2 ?

jrouaix commented 4 years ago

Source here : https://github.com/jrouaix/csharp-expr-rs/blob/420250c9587d44551e80900ca9b08f5b00cdf404/src-csharp/csharp-expr-rs/Native.cs#L46-L56