Giter VIP home page Giter VIP logo

Comments (5)

JohanLarsson avatar JohanLarsson commented on June 16, 2024

How do you suggest doing this given how XmlSerializer works?
I agree that the dependency on Sytem.Xml is not ideal.

from mathnet-spatial.

JKSnd avatar JKSnd commented on June 16, 2024

I would move the responsibility of XML serialization into a set of data transfer objects (DTOs) and use a mapping layer to convert between the core types and the DTOs. This pattern could then be used to add JSON serialization similarly.

Then a developer could add serialization support to their project through Nuget by installing MathNet.Spatial.Serialization.Xml, for example. Units.Net does something similar.

from mathnet-spatial.

Jones-Adam avatar Jones-Adam commented on June 16, 2024

I can move support for serialization from the system.runtime.serialization (DataContracts etc) into a separate (.netstandard2.0 - possibly 1.6) assembly (and at the same time improve serialization support). This is fairly straight forward and works well and as you say should extend to being able to support json too.

However, with regards to the native XmlSerializer even with DTOs the use experience is not great as you cannot (at least as far as I can find) intercept the type lookup for nested types. This would mean converting a type tree into a surrogate type tree before serializing and back again after deserialization. This would only work if you were serializing the objects as standalone objects but would fail in the case you embedded a geometry type into your own serializable class. Not really an ideal experience.
An option would be to drop support for XmlSerializer and either just support data contracts or also support a 3rd party xml serializing solution like ExtendedXmlSerializer in order to be able to keep existing format compatibility for people who have saved representations of the current types.

Another thing to keep in mind is that the current xml serialization support is incomplete with not all types in the library supporting serialization, so either way there is something to be addressed here.

from mathnet-spatial.

JohanLarsson avatar JohanLarsson commented on June 16, 2024

How big problem is the dependency on System.Xml?
I agree it is not nice but can be convenient.
Next question is how big is the upside?, I don't know if XmlSerializeris used much.

@AQuentin2033 Agreed we should have all types implement IXmlSerializable if we have the dependency.

from mathnet-spatial.

JohanLarsson avatar JohanLarsson commented on June 16, 2024

Not that it matters much for anything but nodatime does things the same way we do.

from mathnet-spatial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.