I'm struggling with the following design issue:
There is a C-Function
void Foo(uint8_t *data, uint32_t length);
Which I want to use in C#. So I create the delegate:
public delegate void Foo_Fcn([MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)]byte[] data, UInt32 length);
public Foo_Fcn Foo;
So, the (I admit: in fact minor) problem here is: I have to pass this second argument in my C# code:
byte[] data = /*...*/;
Foo(data, (UInt32)data.Length);
This seems a bit redundant, I'd prefer to call
byte[] data = /*...*/;
Foo(data);
Is this in any way achievable (without using a 'proxy function')? If yes: How?
public delegate void Foo_Fcn([MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)]byte[] data, [ParamIndex=0, ParamProperty=Length]);or however you can coat it in syntactic sugar.