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

Refactor the Poco serializers to work against Base #2917

Open
Kasdejong opened this issue Oct 16, 2024 · 4 comments
Open

Refactor the Poco serializers to work against Base #2917

Kasdejong opened this issue Oct 16, 2024 · 4 comments

Comments

@Kasdejong
Copy link
Contributor

Kasdejong commented Oct 16, 2024

Change the serializers to use the new IScopedNode interface.

@ewoutkramer
Copy link
Member

ewoutkramer commented Oct 17, 2024

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
Copy link
Member

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
Copy link
Contributor Author

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

@ewoutkramer ewoutkramer changed the title Refactor the Poco serializers to work against the new Poco interfaces Refactor the Poco serializers to work against Base Oct 23, 2024
@ewoutkramer
Copy link
Member

ewoutkramer commented Oct 23, 2024

  • I have not added overloads for readers/writers to the IFhirSerializationEngine, since it makes implementing that interface harder. If people need more power to work against streams, you can always use the PocoXml/PocoJson serializers directly instead of via the interface.
  • We have added extension methods for IFhirSerializationEngine that allow you to serialize to streams for resources and, via an explicit overload, also via Base (elements in the tree).
  • The BaseFhirXmlSerializer will serialize an element with a root specifying its typename, unless an explicit name is given.

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

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

  • The `FhirJsonConverter() constructors, use the ForFhir() extension methods on the JsonSerializerOptions instead.

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