FirelyTeam / firely-net-sdk

The official Firely .NET SDK for HL7 FHIR
Other
829 stars 345 forks source link

Refactor the Poco serializers to work against Base #2917

Closed Kasdejong closed 2 weeks ago

Kasdejong commented 1 month ago

Change the serializers to use the new IScopedNode interface.

ewoutkramer commented 1 month ago

I am not sure this is beneficial. It allows us to cover the minor usecase of using the parents element name when serializing subtrees of resources (which officially does not exist) but otherwise, serialization does not need a parent, and so the current itypedelement based direct implementation on pocos would introduce overhead to serialization (including calculation Value) for little profit. If we want to move away from using IROD we should probably just write the serializers against POCO directly, it internally assumes it is using pocos anyway.

ewoutkramer commented 1 month ago

Another note: to make it possible to maintain correct XML ordering, we need to make sure the XML poco parser annotates the nodes with the order, so it can be maintained. We can also add an AddWithOrder extension method to base, so XML users can add elements to (dynamic) resources AND influence the ordering/insert new elements between existing elements.

Kasdejong commented 1 month ago

We should also extend IFhirSerializationEngine to allow for "Base" (de)serializing

ewoutkramer commented 1 month ago

⚠ I have changed the PocoXml/Json serializers to work against Base, not IReadOnlyDictionary<>

⚠ I have removed the following methods that were already obsolete: