Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes for AOT compilation #110

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
Fix offset rollback during serialization for derived types in AOT mode
I'm not positive if it was actually variable boxing, but I was getting an issue where
the value of offset would roll back to the value it was at the last time the specific
SerializeDelegate for that type was used, which would then blow up on deserialization.

Moving the args definition inside the delegate body fixes it
  • Loading branch information
Alex Swaim committed Dec 31, 2023
commit 7b9f205a4956c088d2dbf08f3d0487617ab59008
5 changes: 2 additions & 3 deletions src/Ceras/Formatters/ReferenceFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,9 @@ static SerializeDelegate<T> CreateSpecificSerializerDispatcher_Aot(Type type, IF
}

// Can't call directly, need to invoke through reflection so T gets casted up/down correctly.
var args = new object[3];
return (ref byte[] buffer, ref int offset, T value) =>
{
var args = new object[3];
args[0] = buffer;
args[1] = offset;
args[2] = value;
Expand All @@ -559,10 +559,9 @@ static DeserializeDelegate<T> CreateSpecificDeserializerDispatcher_Aot(Type type
// return (ref byte[] buffer, ref int offset, T value) => { f.Serialize(ref buffer, ref offset, value); };
}


var args = new object[3];
return new DeserializeDelegate<T>((byte[] buffer, ref int offset, ref T value) =>
{
var args = new object[3];
args[0] = buffer;
args[1] = offset;
args[2] = value;
Expand Down