Comments (4)
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.
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.
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.
Resubmit issue in MemoryPack.
Cysharp/MemoryPack#191
from magiconion.
Related Issues (20)
- I can't have multiple implementations! HOT 1
- .NET 8 Support
- Client filter is not triggered for ServerStreamingResult method in services. HOT 1
- Performance is very slow, taking 355ms for the Add function to return the result HOT 2
- How can I disconnect a client by server?
- InternalsVisibleTo lead to warnings on dependent project HOT 1
- Implement Protobuf Endpoint
- ServerReflection does not work
- Cannot work after changing to MemoryPack HOT 2
- Console app probem: PlatformNotSupportedException HOT 1
- support webgl? HOT 2
- error CS0305: Using the generic type 'MemoryPackWriter<TBufferWriter>' requires 1 type arguments HOT 3
- Memory leak when reusing GrpcChannel on many clients HOT 1
- Can't lunch Swagger if I use Vector2 for the communication
- The type or namespace name 'MessagePack' does not exist in the namespace 'MagicOnion.Serialization' HOT 2
- Question: Is there a way to force the server to disconnect the client's connection when using the streaminghub?
- StreamingHub has already been disconnected from the server
- MagicOnion Template Project
- Is it possible to log StreamingHub's input argument values? HOT 1
- Error CS0234 The type or namespace name 'MagicOnion' does not exist in the namespace 'MessagePack.Formatters' (are you missing an assembly reference?) HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magiconion.