Closed inethui closed 2 years ago
Please use Release configuration of AqlaSerializer
Not sure what you mean "Release configuration". Can you be more specific?
AqlaSerializer in debug build performs additional checks to ensure that serialization with compilation and without produces same bytes.
Does Aqla support read-only properties? I found a situation which is supported by Protobuf-net but not by Aqla. The protobuf-net test "CloneReadOnlyPropertyWithProtobuf" in the following code works but the aqla test "CloneReadOnlyPropertyWithAqla" fails with error message:
System.InvalidOperationException : System.String Text: Cannot apply changes to property PrototypeTests.ReadOnlyPropertyTests+WithReadOnlyProperty.Text
---- System.InvalidOperationException : Cannot apply changes to property PrototypeTests.ReadOnlyPropertyTests+WithReadOnlyProperty.Text
public class ReadOnlyPropertyTests
{
[ProtoContract]
private class WithReadOnlyProperty
{
public WithReadOnlyProperty()
{
}
public WithReadOnlyProperty(string text)
{
Text = text;
}
[ProtoMember(1)]
public string Text { get; }
}
[Fact]
public void CloneReadOnlyPropertyWithProtobuf()
{
var obj = new WithReadOnlyProperty("test");
var clone = ProtoBuf.Serializer.DeepClone(obj);
Assert.Equal(obj.Text, clone.Text);
}
[Fact]
public void CloneReadOnlyPropertyWithAqla()
{
var obj = new WithReadOnlyProperty("test");
var clone = AqlaSerializer.Serializer.DeepClone(obj);
Assert.Equal(obj.Text, clone.Text);
}
}
Please set method MetaType.AddField
parameter useBackingFieldIsNoSetter
to true
. protobuf-net removed this parameter.
We use protobuf attributes in this case. How to set useBackingFieldIsNoSetter? Is there a global setting for this?
No, you can only set it with MetaType.AddField
.
I also removed this parameter in develop branch.
I tried the develop branch, the problem is still there. Are you able to run the test code I posted?
BTW I'm using the debug build as I'm having trouble to create a release build of Aqla. Is this a problem?
When I tried to run a release build (with VS 2022 community edition), I got the following error:
Error MSB3644 The reference assemblies for .NETFramework,Version=v4.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
I went to "https://aka.ms/msbuild/developerpacks" but the Developer Pack 4.0 isn't available anymore. Any idea how to get around this? Can you add the support of .NET Framework 4.8?
You have to either use VS2019 or remove not supported target frameworks in the csproj. You can also continue running DEBUG configuration but set RuntimeTypeModel.SkipCompiledVsNotCheck = true
.
Set ((AutoAddStrategy)model.AutoAddStrategy).UseBackingFieldsIfNoSetter = true;
This works, thank you!
I got the error in our tests:
Non-public member cannot be used with full dll compilation
I didn't call the "Compile" method, how could the "full dll compilation" being triggered? Any idea what could be wrong? The same code works fine with Protobuf-net 2.4.6.
Thanks
This is the call stack: