Support for struct ISerializer? #189
Replies: 2 comments 7 replies
-
If you have a ref struct serializer, I think you would also need the new Also, I think I want to support async, which will mean no ref variables of any kind. Lastly, I did previously have that API and I did look at the codegen. Not a good win, surprisingly. In almost all cases I tested it was improving performance by maybe 1%, but it was making the binary significantly larger in Native AOT due to the specialized codegen, and it was increasing compile times. I'll think about adding such an API, but right now I'm not inclined to fork the API if I want to support both async and sync. |
Beta Was this translation helpful? Give feedback.
-
@agocke Are the methods on example gen: partial record struct PrimaryObjectHeader : Serde.ISerialize<Fulcrum.Rio.Services.Vector.PrimaryObjectHeader>
{
void ISerialize<Rio.Services.Vector.PrimaryObjectHeader>.Serialize(Rio.Services.Vector.PrimaryObjectHeader value, ISerializer serializer)
{
var _l_typeInfo = PrimaryObjectHeaderSerdeTypeInfo.TypeInfo;
var type = serializer.SerializeType(_l_typeInfo);
type.SerializeField<Rio.Services.Vector.ObjectType, Rio.Services.Vector.ObjectTypeWrap>(_l_typeInfo, 0, value.ObjectType);
type.SerializeField<Rio.Services.Vector.ObjectFlags, Rio.Services.Vector.ObjectFlagsWrap>(_l_typeInfo, 1, value.ObjectFlags);
type.SerializeField<uint, UInt32Wrap>(_l_typeInfo, 2, value.ObjectPayloadLength);
type.SerializeField<ushort, UInt16Wrap>(_l_typeInfo, 3, value.ExtentLength);
type.SerializeField<long, Int64Wrap>(_l_typeInfo, 4, value.NextExtentOffset);
type.End();
}
} Since my |
Beta Was this translation helpful? Give feedback.
-
Was toying with a ref struct
ISerializer
that would write to aSpan<byte>
. But I would need to avoid boxing the serializer instance. Do you think that changingISerialize<T>
to:Would be worth it to allow this use case? (Might also allow the JIT to devirt the
ISerializer
method calls 🤔)Beta Was this translation helpful? Give feedback.
All reactions