There is a pattern (for XmlSerializer) that the Foo property will also look for either "bool FooSpecified" or "bool ShouldSerializeFoo ()" - and if it is found, only serialize Foo if this other member returns true. So, I believe that the IDSpecified agency has never been set to the truth? Removing this member will always make it serialized (unless you add [DefaultValue] or the like).
This type of behavior is used to model optional values โโin the case when we really need to know if it was in the source data, i.e. does it have a value of 0 because the caller told us that number or because it is simply the default.
Note that the โFooSpecifiedโ member usually has [XmlIgnore] , so the XmlSerializer knows that it cannot be considered as data for serialization. This is optional (or legal) with "ShouldSerializeFoo ()", as methods are never serialized.
source share