This is a documented feature.
http://msdn.microsoft.com/library/en...ClassTopic.asp
If you have in a single class
fieldName
and
fieldNameSpecified
where fieldName is anything and fieldNameSpecified is a bool, the latter is
treated specially. It indicates whether the field "fieldName" has been
specified. If false, then "fieldName" will not be serialized.
This means if you extended your original example class to be:
public class AClass {
/* 1 */ public bool FurtherActionsRequired;
/* 2 */ public bool FurtherActionsRequiredSpecifiedXXX;
/* 3 */ public bool FurtherActionsRequiredSpecified;
/* 4 */ public bool FurtherActionsRequiredSpecifiedSpecified;
}
And if you had an instance of this class in which all fields were false,
then you would serialize only the 2nd and 4th fields.
The 3rd field, being false, would tell the serializer to ignore the 1st
field.
The 4th field, likewise, would tell the serializer to ignore the 3rd field.
No fields would tell the serializer to ignore the 2nd or 4th fields so they
would be serialized.
If you set all these fields to true, then all fields will be serialized.
Typically the specially named "***Specified" field is attributed with an
XmlIgnore attribute so that it is not serialized, ever.
See the doc I referenced above for the details and an example.
-Dino
"AP" <ad***@indra.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
No it wasn't. Why does one serialize and not the other?
"Jiho Han" <ji******@infinityinfo.com> wrote in message
news:OP**************@TK2MSFTNGP11.phx.gbl... Adam,
Was my last explanation not helpful at all?
Basically, your value-type fields won't serialize without the extra
helper fields.
Jiho
"AP" <ad***@indra.com> wrote in message
news:ei**************@TK2MSFTNGP09.phx.gbl... Take a class:
public class AClass {
public bool FurtherActionsRequired;
public bool FurtherActionsRequiredSpecified;
}
this class serialized to XML produces the following XML output:
<?xml version="1.0" encoding="utf-8"?>
<AClass xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<FurtherActionsRequiredSpecified>false</FurtherActionsRequiredSpecified> </AClass>
Why does FurtherActionsRequired not get serialized to XML? Is this a
bug?
Adam