Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Tada! A new serializer is coming!

Tada! A new serializer is coming!

Scheduled Pinned Locked Moved The Lounge
39 Posts 13 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Super Lloyd

    Hey, The intent of this serializer is to replace JsonSerializer (NOT the .NET Serializer) (i.e it's a document serialize, won't work on WPF/WinForm class, unfortunately...) while being way more compact, support IList, IDictionary (normal and generic version), be strongly typed yet type error tolerant. I also dropped human readability format. Text output is just for (painful) debugging purpose. It also DOES NOT support delegates. *It is, indeed, not perfect....* Also it doesn't support TypeConverter / ValueConverter / ISerializable, but I am thinking to add support for them... So to address each point in detail: - by default it only serialize public fields and property. This can be modified with attribute on the class and/or field/property. - what about versioning? It doesn't care if the property is missing while deserializing it is ignored - class invariant... Right now one can enumerate all **reference** object deserialized with the ObjectContext of the deserializer. **I was thinking / maybe** to go one step further and create an IDeserialized interface to automatically "awake / complete" objects after deserialization - also difficult type to serialize can be helped with an "easy" to implement ISurrogate<> class, define this class to replace problematic type when serializing / deserializing

    public interface ISurrogate {
    void Initialize(T value); // called when serializing
    T Instance(); // called when deserializing
    }

    - thinking of WPF.. I just realized that some readonly property (such as Children UI component) while being readonly, can still be serialized as an IList, should be fixed by publication time! ;) Forget that, it cause too much ambiguity about the serizalizer, since it can also (optionally) serialize private field.

    All in one Menu-Ribbon Bar DirectX for WinRT/C# since 2013! Taking over the world since 1371!

    P Offline
    P Offline
    peterchen
    wrote on last edited by
    #28

    Soudns good to me :) `IDeserialized` would allow to cope with many common problems I've encountered. `ISurrogate` could nicely isolate some complexity from the class / serializer itself. Your striked-out part reminds me of another thing: read only Collections (they are managed internally) where the elements are mutable and should be serialized. This could be handled in IDeserialized if I could construct thecollection there and then request serialization for the collection members.

    S 1 Reply Last reply
    0
    • P peterchen

      Soudns good to me :) `IDeserialized` would allow to cope with many common problems I've encountered. `ISurrogate` could nicely isolate some complexity from the class / serializer itself. Your striked-out part reminds me of another thing: read only Collections (they are managed internally) where the elements are mutable and should be serialized. This could be handled in IDeserialized if I could construct thecollection there and then request serialization for the collection members.

      S Offline
      S Offline
      Super Lloyd
      wrote on last edited by
      #29

      Great to know IDeserialized works out for you! :) I needed such concept for my IoC+IServiceProvider to completely initialize object tree (it's called IRegistryDelegate for that). Came with that there first! :-D After all the comments I decided to add yet more functionalities and now it's all broken.... Plus, exceptionally, I work this Saturday! :(( (this my home project, not the work one) So it's gonna be delayed some more... But the current (broken) version does support ISerializable (but not [SerializableAttribute] which assume private field reading), TypeConverter (but not ValueSerializer which are not PLC / .NET Core) and it also support restoring public readonly reference property, such as:

      public List Children { get; } = new List();
      public Configuration Configuration { get { return existingConfig; } }

      I was misleaded, proved easy and helpful! :) ETA should be end of next week now...

      All in one Menu-Ribbon Bar DirectX for WinRT/C# since 2013! Taking over the world since 1371!

      P 1 Reply Last reply
      0
      • S Super Lloyd

        Great to know IDeserialized works out for you! :) I needed such concept for my IoC+IServiceProvider to completely initialize object tree (it's called IRegistryDelegate for that). Came with that there first! :-D After all the comments I decided to add yet more functionalities and now it's all broken.... Plus, exceptionally, I work this Saturday! :(( (this my home project, not the work one) So it's gonna be delayed some more... But the current (broken) version does support ISerializable (but not [SerializableAttribute] which assume private field reading), TypeConverter (but not ValueSerializer which are not PLC / .NET Core) and it also support restoring public readonly reference property, such as:

        public List Children { get; } = new List();
        public Configuration Configuration { get { return existingConfig; } }

        I was misleaded, proved easy and helpful! :) ETA should be end of next week now...

        All in one Menu-Ribbon Bar DirectX for WinRT/C# since 2013! Taking over the world since 1371!

        P Offline
        P Offline
        peterchen
        wrote on last edited by
        #30

        Super Lloyd wrote:

        So it's gonna be delayed some more...

        No worries, I'll be on vacation for a week. :rolleyes: (I expect it on my desk when I return, 9am point ;P )

        S 2 Replies Last reply
        0
        • P peterchen

          Super Lloyd wrote:

          So it's gonna be delayed some more...

          No worries, I'll be on vacation for a week. :rolleyes: (I expect it on my desk when I return, 9am point ;P )

          S Offline
          S Offline
          Super Lloyd
          wrote on last edited by
          #31

          9am sharp! alright! :laugh:

          All in one Menu-Ribbon Bar DirectX for WinRT/C# since 2013! Taking over the world since 1371!

          1 Reply Last reply
          0
          • S Super Lloyd

            For (my extremely slowly) upcoming take over the world project I created a new (C#) serializer! Why? Well this take over the world project, without disclosing too much, is a document editor. I need to save those documents. Writing a Save() and Read() method is quite cumbersome... Serializer, XML Serializer and DataContractSerializer don't make the cut for obvious reason. JsonSerializer is too bloated (think a list of 1000 points, endlessly repeating "x =" or "{" or "}") plus it doesn't work very well with property of type object or List Enter my serializer, it's version tolerant, strongly typed, have some kind of header with all type info, then it's a stream of value and I think it's output quite a compact stream of data. And it works with PCL (i.e. desktop, UWP, IOS, Android, Linux with .NET core) And it just finally worked! this morning at 8:35AM! ;P (well, not completely.. I just tweaked a test which then failed.. apparently there is still a known bug...) Well all of that to say... I might make a CodeProject article if there is some interest for it! ;) As a side note, Not really a GitHub project since it's smack in the middle of my utility library and removing it is .. tedious since I shared plenty of reflection extension method....

            All in one Menu-Ribbon Bar DirectX for WinRT/C# since 2013! Taking over the world since 1371!

            H Offline
            H Offline
            HenryWDC
            wrote on last edited by
            #32

            Just curious, why not something like the Avro serializer (Serializing data with the Microsoft .NET Library for Avro[^]) or Protocol Buffers (https://developers.google.com/protocol-buffers/docs/csharptutorial[^])? Avro supports schemas and versioning, and both produce a fairly compact output and are cross platform compatible.

            S 1 Reply Last reply
            0
            • H HenryWDC

              Just curious, why not something like the Avro serializer (Serializing data with the Microsoft .NET Library for Avro[^]) or Protocol Buffers (https://developers.google.com/protocol-buffers/docs/csharptutorial[^])? Avro supports schemas and versioning, and both produce a fairly compact output and are cross platform compatible.

              S Offline
              S Offline
              Super Lloyd
              wrote on last edited by
              #33

              I was about to replay (once again, like 2 thread above above protocol buffer): Ignorance. But then, following your link (for Avro serializer at least) and going down the memory lane on protocol buffer with a CP Article, the answer is obvious: I want something as simple as NewtonSoft JsonConverter. It should just work! And also it should work with object or subclass. And while you can use some attribute with it, it should work fine without any! In a word I want to serialize that (without any more hidden work!):

              class Data {
              public object Something;
              public List MoreThings { get; } = new List();
              }

              All in one Menu-Ribbon Bar
              DirectX for WinRT/C# since 2013!
              Taking over the world since 1371!

              1 Reply Last reply
              0
              • C Chris Maunder

                Super Lloyd wrote:

                might make a CodeProject article if there is some interest for it!

                Yes please!

                cheers Chris Maunder

                S Offline
                S Offline
                Super Lloyd
                wrote on last edited by
                #34

                No article just yet... But code is on GitHub! GitHub - superlloyd/Galador.Reflection[^]

                A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

                1 Reply Last reply
                0
                • M Marc Clifton

                  Super Lloyd wrote:

                  since I shared plenty of reflection extension method....

                  An article in itself. I've been having fun with reflection and LINQ, but I'd really like to see some cool reflection extension methods, as well as that serializer that you describe. Marc

                  Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny

                  S Offline
                  S Offline
                  Super Lloyd
                  wrote on last edited by
                  #35

                  No article just yet... But code is on GitHub! And I have 2 other reflection goodie inside! ;) GitHub - superlloyd/Galador.Reflection[^]

                  A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

                  1 Reply Last reply
                  0
                  • J Jorgen Andersson

                    I would read it, so yes please.

                    Wrong is evil and must be defeated. - Jeff Ello

                    S Offline
                    S Offline
                    Super Lloyd
                    wrote on last edited by
                    #36

                    No article just yet... But code is on GitHub! GitHub - superlloyd/Galador.Reflection[^]

                    A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

                    1 Reply Last reply
                    0
                    • P peterchen

                      Super Lloyd wrote:

                      So it's gonna be delayed some more...

                      No worries, I'll be on vacation for a week. :rolleyes: (I expect it on my desk when I return, 9am point ;P )

                      S Offline
                      S Offline
                      Super Lloyd
                      wrote on last edited by
                      #37

                      phew, just before your vacation ends! GitHub - superlloyd/Galador.Reflection[^] That's just the GitHub version... CP article still coming....

                      A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

                      P 1 Reply Last reply
                      0
                      • S Super Lloyd

                        phew, just before your vacation ends! GitHub - superlloyd/Galador.Reflection[^] That's just the GitHub version... CP article still coming....

                        A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

                        P Offline
                        P Offline
                        peterchen
                        wrote on last edited by
                        #38

                        I'm impressed! The introduction on GitHub already looks good - haven't dug deeper yet, though.

                        S 1 Reply Last reply
                        0
                        • P peterchen

                          I'm impressed! The introduction on GitHub already looks good - haven't dug deeper yet, though.

                          S Offline
                          S Offline
                          Super Lloyd
                          wrote on last edited by
                          #39

                          Thanks! :) Just committed some performance improvements! CodeProject article is next... might take a while...

                          A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups