Hi there,
I have defined the following .NET Interface:
[Guid("3E927F85-2966-45DC-9CA4-63C7ED18F38F"), ComVisible(true)]
public interface ICoreTestFactory : IHYCrossPlatformInterface
{
Guid TestGuid(Guid id);
}
The implementation is basic, it just returns the passed in Guid.
public Guid TestGuid(Guid id)
{
return id;
}
If I use the Hydra import tool, and import the interface into Delphi. I get the following.
Notice that the id parameter is const.
ICoreTestFactory = interface(IHYCrossPlatformInterface)
['{3E927F85-2966-45DC-9CA4-63C7ED18F38F}']
function TestGuid(const id: TGuid): TGuid; safecall;
end;
The following unit test crashes the test runner (DUnit) hard, when calling the .NET TestGuid Method.
The process just vanishes…
procedure TMyDebugUnitTestCase.Test_MyTest1;
var
Guid1: TGuid;
Guid2: TGuid;
begin
Guid1 := TGuid.NewGuid;
Guid2 := TCoreTestFactory.Instance.TestGuid(Guid1); // crashes here when const
CheckTrue(IsEqualGUID(Guid1, Guid2) );
end;
If I manually remove the const modifier the test works just fine:
ICoreTestFactory = interface(IHYCrossPlatformInterface)
['{3E927F85-2966-45DC-9CA4-63C7ED18F38F}']
function TestGuid(id: TGuid): TGuid; safecall;
end;
When using the const modifier, I put a breakpoint in the .NET method TestGuid.
The id (Guid) argument always had a value of: {0019f4f4-f4e4-0019-20f5-19003b4d2f02}.
In Delphi I am generating random Guids. So the value reaching .NET is already wrong.
I think you will have to adjust your importer so that Guid arguments are not marked as const.
Thanks!