Closed shaggygi closed 2 years ago
What's wrong with protobuf? It has good VS tooling support, requires near zero effort to setup and it's language agnostic too. Just install the nuget package, write your proto schemas, and then VS will generate the stubs and message classes for you.
Usage is as simple as MyType.Parser.ParseFrom(byte[]...);
, or new MyType().ToByteArray();
Thanks @KieranDevvs for the feedback and a good suggestion. However, it would be nice to have more flexibility on the encoding/decoding on the various object properties of different types (int, double, float, etc.) based on the protocol being used. For examples, BACnet doesn't have leading bytes in some scenarios for ints/uints. There also might be cases where you have multiple bool properties that make up certain bits in a byte(s) to be processed. The BinarySerializer
mentioned above appears to have attributes (have not done a deep dive yet) where you can add to the properties to perform the needed conversions and order to do so.
BTW, I don't want to downplay the BinarySerializer project as it might be a good solution. Just was throwing this issue out to see if there was some related thinking/designing being added in Bedrock (or elsewhere within the core .NET libs) that would support (giving the warm/fuzzies a long-term solution 😄).
Understood, was mainly curious on thoughts. Never heard of some of those mentioned I'll check out. Thx
@shaggygi There is also Microsoft Bond, which supports 3 different formats for serialization, including 3 separate protocols:
@jzabroski thank you for the info 👍
Would be a nice-to-have serializer like the following for a standard approach on converting data to/from objects.
https://github.com/jefffhaynes/BinarySerializer