Fix Version marshaling as parameter

This commit is contained in:
Wojtek Figat
2025-03-06 00:36:39 +01:00
parent 196ada5710
commit 8e2f3ec0c0
4 changed files with 27 additions and 96 deletions

View File

@@ -232,7 +232,13 @@ namespace FlaxEngine
internal static ManagedHandle VersionToManaged(int major, int minor, int build, int revision)
{
Version version = new Version(major, minor, Math.Max(build, 0), Math.Max(revision, 0));
Version version;
if (revision >= 0)
version = new Version(major, minor, Math.Max(build, 0), revision);
else if (build >= 0)
version = new Version(major, minor, build);
else
version = new Version(major, minor);
return ManagedHandle.Alloc(version);
}
@@ -245,15 +251,6 @@ namespace FlaxEngine
return ManagedHandle.Alloc(new CultureInfo(lcid));
}
[StructLayout(LayoutKind.Sequential)]
internal struct VersionNative
{
public int Major;
public int Minor;
public int Build;
public int Revision;
}
internal static void VersionToNative(ManagedHandle versionHandle, ref int major, ref int minor, ref int build, ref int revision)
{
Version version = Unsafe.As<Version>(versionHandle.Target);