Nullable types versus "ValueTypeFieldSpecified" field

Oct 5, 2009 at 1:19 PM

Me again...

I was wondering if you could provide me with your thinking on nullable types versus the "ValueTypeFieldSpecified" field convention.

I understand the history of use for "MyFieldSpecified". I expected to see this replaced with Nullable types in the code generated by WSCF.blue but it isn't. Can you tell me your reasoning behind this? Is it simply a "hangover" from the original WSCF implementation or is there some serialization nastiness?

Thanks,

Callum

Developer
Oct 5, 2009 at 2:12 PM
Edited Oct 5, 2009 at 2:52 PM

Hi Callum,

If you have a type such as xs:int in your contract that is nillable you should get a Nullable<int> in the generated code.

For example:

<xs:element name="fooId" type="xs:int" nillable="true" />


Should be generated as:

[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
public System.Nullable<int> fooId


A type such as xs:string will only receive the attribute. Are you seeing something different to this? If so, can you provide an example?

Cheers,

Alex.

Oct 5, 2009 at 2:43 PM

I was putting minOccurs="0" rather than nillable="true".

That makes sense now. I was being a bit stupid.

Thanks,

Callum

Developer
Oct 5, 2009 at 2:48 PM
Edited Oct 5, 2009 at 2:52 PM

No problem Callum. It's often the simple things we overlook. :)