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

Serialization of .NET 6.0 DateOnly with actors #314

Open
RemcoBlok opened this issue Mar 17, 2022 · 2 comments
Open

Serialization of .NET 6.0 DateOnly with actors #314

RemcoBlok opened this issue Mar 17, 2022 · 2 comments

Comments

@RemcoBlok
Copy link

RemcoBlok commented Mar 17, 2022

Service Fabric using the DataContractSerializer does not currently support serialization and deserialization of .NET 6.0 DateOnly type used in dto's, parameters or return values. Can you advise how I can add this support? I'm not sure how to do this with the DataContractSerializer.

I know how to add this support using custom converters when using a json serializer (either Newtonsoft or System.Text.Json). So I looked at the example here Use custom serialization with a remoting wrapped message for how I might replace the DataContractSerializer with a json serializer.

A couple of issues:

I use v2 remoting but not the interface compatible v2.1 as I cannot use wrapped messages. I tried using v2.1 with wrapped messages but it does not work for some reason. Perhaps it does not work because I already customize the client and listener so that I can add custom headers containing context to the transport .

I want to use System.Text.Json and not Newtonsoft. How should I implement polymorphic deserialization which needs to be implemented using a custom converter as discussed here Support polymorphic deserialization, when I'm not directly (de)serializing my dto's / parameters / return values, but I'm (de)serializing a IServiceRemotingRequestMessageBody or IServiceRemotingResponseMessageBody. I will need to serialize the type information.

Specifically when using actors I may need to do something similar to the ActorDataContractSurrogate and ActorReference used by ActorRemotingDataContractSerializationProvider when using a json serializer

@RemcoBlok
Copy link
Author

I have a working solution now that appears to do the job. I created a repo here:
https://github.com/RemcoBlok/ServiceFabric.Remoting.Json

It can serialize and deserialize DateOnly types using System.Text.Json
It can also do polymorphic deserialization.
It uses non-wrapped messages. So using remoting v2, not remoting v2.1.

I added a converter for IActor using an ActorReference similar to the ActorDataContractSurrogate, but it does not get used. I like to understand if it is needed at all.

I still need to perform loadtesting of our system with the new serialization to see if how it performs under load. The standard DataContractSerializer seems to use IPooledBuffer instead of ArraySegment. I use ArraySegment. My payloads are small so I'm not sure if I need to look into IPooledBuffer. The loadtesting will tell.

It would be really good if the ServiceFabric team could review this and advise where it might need improving.

@pakunapamsft
Copy link
Contributor

The arguments and return types of the remoting methods has to be data contract serializable(https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-services-communication-remoting#set-up-remoting-on-a-service). It seems to me that DateOnly is not Data contract serializable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants