Closed AArnott closed 7 years ago
(Native alignment rules are a pain in the ass, interesting to see that we can't avoid reproducing nested unions like that to get the same effect, I suspect quite a lot of pinvoke.net signatures erasing the unions are actually incorrect)
Thank you for testing, @vbfox. If they're something you can share, it would be great to have in unit tests. In fact we might want to split our unit test project to enforce x86 and x64 testing and use a Shared Project so the tests are in both projects.
My test was running the same code in cpp
int main()
{
INPUT input;
printf("hi=%i\n", (long long)&input.hi - (long long)&input);
printf("mi=%i\n", (long long)&input.mi - (long long)&input);
printf("ki=%i\n", (long long)&input.ki - (long long)&input);
return 0;
}
And C#
unsafe void Main()
{
INPUT input;
Console.WriteLine("hi={0}", (long)&input.Inputs.hi - (long)&input);
Console.WriteLine("mi={0}", (long)&input.Inputs.mi - (long)&input);
Console.WriteLine("ki={0}", (long)&input.Inputs.ki - (long)&input);
}
In both x64 & x86 and checking that the result match. Being able to have unit tests that check that the value are correct in both x86 & x64 would be perfect regresion-wise.
Bump version to 0.4 due to the breaking change.
Fixes #309