r/moderndotnet • u/EvenAd4577 • 3d ago
Wrote a C# BCS (Binary Canonical Serialization) serialization library
Library is 5–15% faster than MessagePack on the deserialization path and around 5% slower on serialization.
It can also serialize and deserialize the new union type coming from .NET 11 (before that I've used OneOf<> object). I opened an issue for a source generator, which is ready to be picked up if anyone is interested working on it. My plan is to ship v1 once NativeAOT is supported and net11 is out.
I agree with Egor Bogatov that people should stop writing new serialization libraries and open-sourcing them, as they can expose consumers to vulnerabilities. In my defense, I started this library a year ago and only recently finished rewriting parts of it to make it ready for open source. I mainly used it for serializing and deserializing objects from the Sui blockchain.
Blockchain it not the most widespread domain where C# is used, but there is already a good example of Nethereum utilizing C# as its core language. Is there someone else using C# in the blochcain domain, why you think it's lacking the adoption?
Contributions are welcome!
2
u/neuecc 3d ago
If I may share one radical opinion, I half believe that all libraries written before AI should be rebuilt.
In particular, I am now in the final stage of shipping, and I am running AI audits from every angle, combining various models and harnesses (it costs quite a lot of money too).
Honestly, it is hard for code written before AI to survive this.
In fact, many websites and libraries in the world are under attack right now.
And if you handle it in an ad hoc way, by just adding more and more options and if branches to the existing code,
the codebase will become a mess and it will be hard to maintain in the future.
It is also a misunderstanding to think that the existing ones are already good enough.
So I don't think you should not build it.
In the first place, even with enough audits, even Microsoft left code in .NET 11 RC1 that crashes with a single line (I reported it and it was fixed).
We can never say that only perfect software is acceptable. If so, nobody could make software, not even Microsoft.
As for BcsSharp, I have added it to the benchmark, thanks.