and define my structures as
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TArticleInfoItem
{
// input fields (delphi application -> WWKS2 lib)
[MarshalAs(UnmanagedType.BStr)]
public string cnk;
[MarshalAs(UnmanagedType.BStr)]
public string name;
[MarshalAs(UnmanagedType.BStr)]
public string dosageinfo;
[MarshalAs(UnmanagedType.BStr)]
public string packagingunit;
public int extra;
}
however hydra functions like
public interface IWWKS2VendingMachinePluginFeedback : IHYCrossPlatformInterface
{
bool askArticlePriceInfo(string cnk, out TArticlePriceInfoItem item);
do not fill in the fields correctly.
Currently it looks like only the first half of the strings are copied.
Zero length strings are also null in the receiving .NET plugin.
Does records/structures communication work? If so, how?
How the askArticlePriceInfo method is defined on the Delphi side?
Actually please create a testcase app: a simple .NET plugin and a Delphi host app, just covering this one method and structure type and demonstrating the issues you have.
Attached is a sample that fails.
Callback method 1 fails with this code.
However, when I changed the struct it was callback method 2 that failed.
A big issue which I reported earlier also is the fact that the generated code does not compile because it is missing the structures
Could it be that there is something more fundamentally wrong?
I have other code where ref crashes
Some code only passes half of the string (first half of the characters)
In any case I assume you want out also to work?
At present no code is generated for structures, will you be adding this functionality?
At present the generated delphi code DOES NOT COMPILE when structures are in the interface!
Main issue is that documentation should have mentioned that structures are a very low-level approach and should only be used in case of performance issues. More recommended way of work is to use/pass interfaces, not directly in-memory structures. Actually Hydra tools and approaches were designed for interfaces use, not structures.
Performance comes at the cost of the issues you see like manually-written structures code and properly defined methods (tbh I am not sure if out modifier will work with structures). Otherwise you’ll see hardly-to-catch issues.
IOW it should be not
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TArticleInfoItem
...
It should be
public interface IArticleInfoItem: IHYCrossPlatformInterface
...
Yes. It is expected that if you are going to use low-level stuff then you’ll also write the code required for this. Anyway Importer won’t be able to guarantee that the generated code is correct.