I've been toying with marshalling in F# recently, and to my surprise I ended up with error FS0980: Custom marshallers cannot be specified in F# code. Consider using a C# helper function.
Only information regarding the topic, that I managed to find, is F# 4.0 Spec (page 300)
When applied to a parameter or return type, specifies the marshalling attribute for a CLI P/Invoke stub declaration. This attribute may be used in both F# and imported assemblies. However, F# does not support the specification of "custom" marshallers.
I'm mostly interested in reasons behind lack of custom marshallers support, as I can "live with" introducing C# assembly to project.
Can anyone clarify on this?
EDIT:
Sample code as requested
[<StructLayout(LayoutKind.Sequential, Pack=1)>]
type BASIC_STRUCT =
struct
[<MarshalAsAttribute(UnmanagedType.CustomMarshaler,MarshalTypeRef=typedefof<DateTimeMarshaller>)>]
val timeVar:DWORD
end
from what i noticed just setting UnmanagedType.CustomMarshaler is enough to cause compile time exception