Serialization roadmap #3759
Replies: 2 comments 6 replies
-
I personally don't like marker attributes for this kind of stuff. I see the problem with types you don't have control over but are simpel enough to just be serialized. But because you can't add the attribute to the type you have to work around that limitation to get it work. I argue against marker attributes because I think the restriction is greater than the benefit. |
Beta Was this translation helpful? Give feedback.
-
So my question wasn't entirely hypothetical 😄 https://github.com/JasonBock/CslaGeneratorSerialization It turns out that source generators are most efficient if they can drive off interfaces. So to refine my question, should the "serializable" interface be in CSLA, or in a serializer? |
Beta Was this translation helpful? Give feedback.
-
CSLA has been moving away from
BinaryFormatter
(and NDCS) for years. Microsoft is planning to obsoleteBinaryFormatter
in .NET 9, so I've opened a backlog issue to remove the requirement for using theSerializable
attribute: #3687I'd like to have a discussion about extensibility and serialization.
CSLA still has all the configuration to allow someone to create a different serializer from
MobileFormatter
if they desired. Over the yearsMobileFormatter
has become quite good, but every now and then someone expresses the desire to create something better - and that would be wonderful!The thing about any CSLA serializer/formatter is that it must be full fidelity. Meaning that it either needs to serialize at the field level like
BinaryFormatter
(not at the property level), or it needs to work with the CSLA field manager and other concepts to serialize logical fields. It also needs to handle duplicate references to a single object instance, such that when the graph is deserialized the shape of the graph is identical.Most JSON and XML serializers/formatters don't do these things and so aren't useful.
What I'm saying, is that creating a serializer is hard.
Nonetheless, and here's my question, I wonder if CSLA should define a replacement attribute for
Serializable
to make it easy to identify serializable types - it would be used byMobileFormatter
and could be used by anyone else's serializer in the future.Having an attribute "owned" by CSLA instead of .NET would be a good thing in some ways.
However, there's also an argument to be made that each serializer should define its own attribute (if it needs one). So if you want to use this other serializer, you'd go through all your classes and decorate them with the serializer's attribute.
From a maintainability perspective this could go either way, so I'm interested in people's thoughts.
Beta Was this translation helpful? Give feedback.
All reactions