Skip to content

[Unity] Please consider adding proper UInt64 support for the plugin #2040

Open
@riverreal

Description

@riverreal

detail | 详细描述

As casted here:

setValueApi.SetBigInt(isolate, holder, (long)i);

The C# UInt64 to JS bigint conversion results in having negative values if it exceeds the long limits.
This might look like it has no problems since the data is not lost and indeed converting the bigint back to UInt64 has no problems.
But the biggest problem with this is the incompatibility between JS created bigint values to C# UInt64 bigint values.
This leads to nasty bugs as the behavior might seem normal for values below long's MaxValue, but it does not work well for values above that.

For example, any comparison between those won't work as expected in some cases:

const jsBigInt = CreateSomeBigInt();
const csBigInt = CS.GetSomeBigInt();

// <!> Only works if csBigInt is below long's MaxValue
if (jsBigInt < csBigInt) {
  // Do something
}

If this is the default behaviour Puerts wants to achieve then it should be noted somewhere that UInt64 is not supported fully.
One might expect it to work normally if it's able to convert UInt64 values to bigint but it simply does not.

Usually servers have UInt64 as ID in their table columns, so this incompatibility makes Puerts a bit troublesome when dealing with server responses with these IDs when interloping with C#.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions