Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Make structs readonly #1130
This is the first pass at #1033.
Once #1129 is merged, this is a single commit.
IXmlSerializable is fundamentally broken for readonly structs, but we can cast away the readonly-ness using the System.Runtime.CompilerServices.Unsafe package. It feels like the benefits of this are greater than the downsides.
Basically we're breaking the readonly contract, with all the fun that could entail. If this is used by anyone outside regular XML serialization, I'd expect problems. Within XML serialization, it should be fine - this it all called on new objects.
I'm going to wait until we've got the first benchmarks working for v3 before merging.