Giter VIP home page Giter VIP logo

Comments (4)

neuecc avatar neuecc commented on May 30, 2024

This issue is about MemoryPack.

MemoryLayout compatibility can be a complicated case when not everything is Sequential.
For example, .NET 6/7 compatibility had the following problems
Cysharp/MemoryPack#107 (comment)

As far as I can see, everything is handled as Auto in Unity and Sequential in .
In this case, A is described as SequentialLayout and ValueTuple as AutoLayout, but in .NET 6 and below, the case seems to be similar to the problem in the comment above, where it does not do as specified.

The best thing to do is to not use ValueTuple (make them all Sequential), but as a workaround, making A an AutoLayout may solve the problem.

from magiconion.

AwaharaFujihiro avatar AwaharaFujihiro commented on May 30, 2024

Thank you.

With this sample, it is indeed a MemoryPack issue.
I am sorry for the confusion I caused by explaining it with ValueTuple,
The same issue is happening with MagicOnion.DynamicArgumentTuple.

DynamicArgumentTuple<A, int>(new A { B = 1, C = 2 }, -1);

in .Net, the memory placed by AutoLayout seems to place primitive types first.
I have confirmed that the problem of reversed memory layout order can be avoided by setting DynamicArgumentTuple to Sequential.

from magiconion.

AwaharaFujihiro avatar AwaharaFujihiro commented on May 30, 2024

This code can reproduce the problem with MagicOnion.

Common

[MemoryPackable]
[StructLayout(LayoutKind.Auto)]
// This also occurs when TestStruct is set to Sequential.
public partial struct TestStruct
{
    public int A;
    public int B;
}
public interface ITestService : IService<ITestService>
{
    public UnaryResult SendTest(TestStruct ab, int c, int d);
}

Client (Unity)

var testService = MagicOnionClient.Create<ITestService>(channel);
await testService.SendTest(new TestStruct()
{
    A = 1,
    B = 2,
}, c: 3, d: 4);

Server (.Net)

public UnaryResult SendTest(TestStruct ab, int c, int d)
{
    Console.WriteLine($"A={ab.A}");
    Console.WriteLine($"B={ab.B}");
    Console.WriteLine($"C={c}");
    Console.WriteLine($"D={d}");
    return UnaryResult.CompletedResult;
}

Result

A=3
B=4
C=1
D=2

from magiconion.

AwaharaFujihiro avatar AwaharaFujihiro commented on May 30, 2024

Resubmit issue in MemoryPack.
Cysharp/MemoryPack#191

from magiconion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.