This project is read-only.

Nullable types versus "ValueTypeFieldSpecified" field

Oct 5, 2009 at 2: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 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?



Oct 5, 2009 at 3:12 PM
Edited Oct 5, 2009 at 3: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:

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?



Oct 5, 2009 at 3:43 PM

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

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



Oct 5, 2009 at 3:48 PM
Edited Oct 5, 2009 at 3:52 PM

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