ObjectLayoutInspector
ObjectLayoutInspector copied to clipboard
add SizeOfInstanceFields for Unsafe
SizeOf != SizeOfInstance Fields. needed for networking.
Could you please clarify the issue a bit more?
What is size of this struct, 5 or 8?
[StructLayout(LayoutKind.Explicit)]
public struct ChallengeRequest
{
public static ChallengeRequest Create()
{
return new ChallengeRequest();
}
[FieldOffset(0)]
public RequestMessageType Type;
/// <summary>
/// 0 (using a u32 here since that pads the request to the same size as theresponse)
/// </summary>
[FieldOffset(1)]
public uint Padding;
}
C# sizeof and Unsafe.SizeOf will tell 8, but I want 5. And not using reflection or runtime codegen.
Ok. Now I get it. Thanks. Will fix.
I am not sure if reflection based stuff have or not have that type of API, but unsafe based stuff (which works within AOT), do not have that for sure. But anyway, because it lacked in unsafe part, calculated manually.