[CSHARP-1973] Add Support for System.Runtime.ISerializable for Custom Serialization Created: 01/May/17  Updated: 31/Mar/22

Status: Backlog
Project: C# Driver
Component/s: Serialization
Affects Version/s: 2.4.3
Fix Version/s: None

Type: New Feature Priority: Minor - P4
Reporter: Jerry Wiltse Assignee: Unassigned
Resolution: Unresolved Votes: 3
Labels: size-medium
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

A serialization framework in .NET should understand and support System.Runtime.ISerializable. Presently, the MongoDB C# driver does not appear to have any reference to this interface.

The interface is extremely practical, as it allows for owners of classes to implement the GetObjectData method in their class and define universal logic for serializing their class across any future serializers. This is preferable to having to learn the idiosyncrasies of proprietary serializers and re-write the same serialization logic multiple times depending on the output format and library. The custom serialization abstractions in MongoDB will still be needed for complex scenarios when the GetObjectData does not provide enough flexibility. However, for companies which have already invested significant time and energy into leveraging ISerializable for XML and JSON serialization in their application, and which want to move to MongoDB, it's a significant frustration that this native platform serialization mechanism is not honored.

Json.NET honors the nature of the ISerializable interface and GetObjectData method, and provides a good model for how it should work in the Mongo Driver. While it's not trivial to implement, it doesn't seem difficult either.

http://www.newtonsoft.com/json/help/html/SerializationGuide.htm#ISerializable



 Comments   
Comment by Jerry Wiltse [ 28/Sep/18 ]

Looks right, thanks so much for following up and doing the implementation!

Comment by Lucaci Gabriel [ 28/Sep/18 ]

If you have time please take a look here https://github.com/glucaci/MongoDB-FrameworkSerializer maybe we can integrate it into mongo-driver if it's the way you wanted.

It's still work in progress

Comment by Lucaci Gabriel [ 19/Jul/18 ]

Is this somewhere on the Roadmap?

For a C# driver I think this is not a Minor Priority. Understanding the framework serialization interface should be something higher in my opinion.

This issue was opened more than 1 Year ago.

Thanks!

Comment by Robert Stam [ 03/May/17 ]

Thank you for the suggestion. We will consider it for a future release.

Generated at Wed Feb 07 21:41:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.