It's a mystery to me why XAML wohn't serialize my objects unless the classes have default constructors and why properties wohn't be serialized unless there are setters for the properties. I understand why XAML can't necessarily deserialize instances of such unhelpful classes but the other way around is completely mystifying to me. Zero-parameter constructors also breaks the contract for the class as objects are not properly initialized, hence violating the class invariant.

 

That said, XAML is very nice and a very easy way to serialize objects. I just wish it wouldn't force me to break my class invariants or at least not for serialization scenarios. So I guess until this is fixed my XLinq query will have to do - which in fairness is very succint, it's just that a XAML alternative would be perfect for prototyping and initial debugging.

 

This way of handling object initialization is also at odds with an invariant-style programming where objects are constants. I don't have an answer to pull out of my sleeve but some thought should be put into this.